mercredi 28 mai 2014

SQL serveur ce - DbConnection cueillette de chaîne de connexion incorrecte - Stack Overflow


Earlier i was using SQL Server Compact Data Provider to persist my data and connection string to point to my .sdf file where i intended to store the data. Later on i switched to the SqlClient Data Provider and a new connection string pointing to the SQL server and new database (.mdf).


The problem is when i am creating DbConnection object to open the connection it is picking the SQL Server Compact Data Provider's connection string even though i have removed all references of the SQL Server Compact Data Provider and the connection string from my config file.


Is there any thing that i have missed ?


Update ------


I am using System.Data.SqlClient as dbprovider now and providing it with following connection string


<add name="ServerModel" connectionString="metadata=.\Server.csdl|.\Server.ssdl|.\Server.msl;provider=System.Data.SqlClient;provider connection string='Data Source=servername\SQLSERVER;Initial Catalog=nServices;Integrated Security=True;Connection Timeout=60;multipleactiveresultsets=true'" providerName="System.Data.EntityClient" />

and initalizing objectcontext object as following


ObjectContext= new objectContext(ServerModel); 

which throws an exception syaing -- "Format of the initialization string does not conform to specification starting at index 0."


Where i am going wrong



Earlier i was using SQL Server Compact Data Provider to persist my data and connection string to point to my .sdf file where i intended to store the data. Later on i switched to the SqlClient Data Provider and a new connection string pointing to the SQL server and new database (.mdf).


The problem is when i am creating DbConnection object to open the connection it is picking the SQL Server Compact Data Provider's connection string even though i have removed all references of the SQL Server Compact Data Provider and the connection string from my config file.


Is there any thing that i have missed ?


Update ------


I am using System.Data.SqlClient as dbprovider now and providing it with following connection string


<add name="ServerModel" connectionString="metadata=.\Server.csdl|.\Server.ssdl|.\Server.msl;provider=System.Data.SqlClient;provider connection string='Data Source=servername\SQLSERVER;Initial Catalog=nServices;Integrated Security=True;Connection Timeout=60;multipleactiveresultsets=true'" providerName="System.Data.EntityClient" />

and initalizing objectcontext object as following


ObjectContext= new objectContext(ServerModel); 

which throws an exception syaing -- "Format of the initialization string does not conform to specification starting at index 0."


Where i am going wrong


0 commentaires:

Enregistrer un commentaire