connect windows user name and password

jassie

Well-known member
Joined
Nov 13, 2012
Messages
61
Programming Experience
1-3
In a C# 2008 windows application I found out the following when the application is executed for a task scheduler:
The windows username and password are exactly the same as the sql server username and password.
Thus if the following is in the connection string in an app.config file, the following will use the sql server login and not the
windows user login correct?
<connectionStrings>
<add name="RPCSS_DEVConnectionString"
connectionString="Data Source=dev;Initial Catalog=DEV2;User Id=myUsername;Password=myPassword;"
providerName="System.Data.SqlClient" />
</connectionStrings>
Also can you tell me if there is any way for the windows user name and password to be used when connecting to the
sql server 2008 r2 database? If so, can you tell me what the connection sting would be so I know to avoid that connection string?
 
If you want to login to the database as the current Windows user then you don't provide a User Id or Password and you set Integrated Security to True. If your app is running as a scheduled task then it must run as a user that has a corresponding Login in SQL Server that maps to a User with the appropriate permissions.
 
Back
Top Bottom