6 Replies - 1050 Views - Last Post: 02 July 2012 - 05:14 AM Rate Topic: -----

#1 djenriquez  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 79
  • Joined: 22-November 09

Unable to open connection with SQLServer using Web Services

Posted 29 June 2012 - 10:45 AM

Hello,

I've stuck on an issue where in my web service operation, i cannot establish a connection

I added an ADO.NET Entity Data Model item using Visual Studios 2010 and successfully imported the datamodel deployed on my sequel server.

 public BusinessEntities.MADataModel MADataModel = new BusinessEntities.MADataModel(); 


Visual Studios generated the App.Config file, so I'm using the default constructor which uses the generated Connection String in this file.

In my Silverlight App, attaching the service to the process for debugging, when I push the button that calls the service which instantiates this data model, I get an error "The specified named connection is either not found in the configuration, not intened to be used with the EntityClient provider or not valid." for the method:

public MADataModelEntities() : Base("name=MADataModelEntities", "MADataModelEntities")
{
    OnContextCreated();
}



according to Visual Studio's debugger.

Which is a completely autogenerated method using autogenerated parameters.

If i remove this, and say add a messagebox which outputs an input string from the UI, it displays it back. So I know that the service works.

Any idea why my data model is failing to establish a connection?

Thanks,

DJ Enriquez

This post has been edited by djenriquez: 29 June 2012 - 10:49 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Unable to open connection with SQLServer using Web Services

#2 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,957
  • Joined: 21-March 08

Re: Unable to open connection with SQLServer using Web Services

Posted 29 June 2012 - 11:17 AM

Can you post your app.config file?
Was This Post Helpful? 0
  • +
  • -

#3 djenriquez  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 79
  • Joined: 22-November 09

Re: Unable to open connection with SQLServer using Web Services

Posted 29 June 2012 - 11:32 AM

View Posteclipsed4utoo, on 29 June 2012 - 12:17 PM, said:

Can you post your app.config file?

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <connectionStrings>
    <add name="MADataModel" connectionString="metadata=res://*/MADataModel.csdl|res://*/MADataModel.ssdl|res://*/MADataModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=WSR-MESF01;initial catalog=MA.DataModel.MADataModel;integrated security=True;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
</configuration>


Was This Post Helpful? 0
  • +
  • -

#4 Nakor  Icon User is offline

  • Professional Lurker
  • member icon

Reputation: 441
  • View blog
  • Posts: 1,488
  • Joined: 28-April 09

Re: Unable to open connection with SQLServer using Web Services

Posted 29 June 2012 - 04:02 PM

Is your entity model defined in the same project as the service that's being called? If not you will need to copy the connection string from the app.config in the entity project to the web.config/app.config of the service project.
Was This Post Helpful? 0
  • +
  • -

#5 djenriquez  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 79
  • Joined: 22-November 09

Re: Unable to open connection with SQLServer using Web Services

Posted 29 June 2012 - 04:22 PM

View PostNakor, on 29 June 2012 - 05:02 PM, said:

Is your entity model defined in the same project as the service that's being called? If not you will need to copy the connection string from the app.config in the entity project to the web.config/app.config of the service project.


Yes it is, I added the ADO.NET Entity Data Model item using the Visual Studios 2010 wizard. It allowed me to search and find my datamodel on my server, then went ahead and generated the app.config file upon completion of the wizard.
Was This Post Helpful? 0
  • +
  • -

#6 djenriquez  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 79
  • Joined: 22-November 09

Re: Unable to open connection with SQLServer using Web Services

Posted 01 July 2012 - 08:38 PM

bump, anyone else see anything wrong? Maybe its because the functionality is being used by the web service? So something needs to be different maybe...?
Was This Post Helpful? 0
  • +
  • -

#7 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,957
  • Joined: 21-March 08

Re: Unable to open connection with SQLServer using Web Services

Posted 02 July 2012 - 05:14 AM

I've seen this happen before. Not sure why, but I think it might be a bug in the way EF generates the connection string.

Attached Image

Change those to the actual quote characters.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1