When I want to connect to SQL Server 2008 via SSMS in windows authentication mode I get the following error:
login failed for user UserDomainName\UserName
I installed my SQL Server in mix mode and set user to NT Authority\system , how can I create a connection string with "UserDomainName\UserName" user not with "NT Authority\system" user in C#?
Store the connection string in Web.Config or App.Config file
<connectionStrings>
<Add name="CS" ConnectionString="DataSource=.;Database=Sample;Integrated Security=SSPI" ProviderName="System.Data.SqlClient"/>
</connectionStrings>
then you can read the connection string property using System.Configuration namespace (dll)
string conStr = ConfigurationManager.ConnectionStrings["CS"].ConnectionString;
how can I create a connection string with "UserDomainName\UserName" user not with "NT Authority\system" user in C#?
Then use SQL Authentication mode and not windows authentication
ConnectionString="DataSource=.;Database=Sample;user id = test; password=test"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With