Saturday, March 24, 2012

Windows authentication vs. SQL "sa" authentication

I don't have necessary rights on my local machine at work to use SQL administrative "sa" and password when utilizing sql connections. My Windows network username and password does allow me to connect to local SQL database (MDSE) when I view the database scheme in visualstudio.net (PROG1\NETSDK ).
When I need to create an sql connection string, :

using System.Data.SqlClient;

string source = "server=(local)\\NetSDK;" +
"uid=QSUser;pwd=QSPassword;" +
"database=marketing";

SqlConnection conn = new SqlConnection(source);
conn.Open();

..how would I specify my windows network username/pwd, opposed to an sql administrative type shown above?

Thx
ChumThis is how you would do it. In ASP.NET the account trying to log into the database under windows authentication is the account you are runnig IIS under.

server=DatabaseServer;Trusted_Connection=true;database=DataBaseName;

0 comments:

Post a Comment