Skip to content Skip to sidebar Skip to footer

Web.config Entry To Connect To Sql Server

Well I'm trying to change the connection of my application from Oracle to SQL Server. I have this in web.config. ...

Solution 1:

The only 2 lines you need to connect to SQL Server is:

<connectionStrings><addname="CnString"providerName="System.Data.SqlClient"connectionString="Data Source=(local)\\MSSQLSERVER;Initial Catalog=TESTDATABASE;User Id=TESTUSER;Password=TESTPASSWORD;"/></connectionStrings>

and

<assemblies><addassembly="System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /></assemblies>

(change version and publicKeyToken in case of .NET 2.0/3.x)

Then use:

SqlConnectionconnection=newSqlConnection("CnString");
// ...

That's it.


In .NET there is no such assembly as System.Data.SqlClient, Version=10.50.1600, .... SqlClient is the part of standart .NET Framework distribution.

For example, System.Data.SqlClient.SqlConnection:

Namespace:  System.Data.SqlClientAssembly:  System.Data (in System.Data.dll)

Post a Comment for "Web.config Entry To Connect To Sql Server"