Wednesday, March 28, 2012

How to establish connection to SQL Server?

in the Quick start, it used connection string ("server=(local)\NetSDK;database=pubs;Trusted_Connection=yes") to connect to the SQL db.

Now my working environment is, Im working on my client running .NET Framework as a webserver, and the SQL Server is on another PC as a db server (IP: xxx.xxx.xx.xx, user: webuser, pwd: webuser).

1st Question:
how do I build my connection string for this??
I tried following but no luck:
"user id=webuser;password=webuser;Initial Catalog=Bei;Data Source=xxx.xxx.xx.xx;Integrated Security=SSPI;";

2nd Question:
I just happened to see that ODBC is no more recommended in ASP.NET ?? if that's the case what is the new way to connect to DB ?? by using connection string or what ??

Thanks heaps!
Beiok, with luck the connection string works.
"Data Source=159.215.146.21,1433;Network Library=DBMSSOCN;Initial Catalog=Bei;User ID=webuser;Password=webuser;"

however, I still want to know what is the recommended way for DB connection from ASP.NET ?? No more ODBC ??

Thanks|||The recommended provider is the naitive SQL Server one. So not ODBC or OLEDB. The connection string looks something like:
"data source=YourServerName;initial catalog=YourDatabase" - not really any different, just don't put in any provider details. The User credentials part will depend upon if you can use integrated security or not.|||Thanks dude, this definitely helped!

No comments:

Post a Comment