Reputation: 51
How to write the connection string to local SQL Server database using web.config
?
Here is my connection string in web.config
. But when I open local/demo, it said:
login failed for user ''.
Actually I'm using Windows authentication, so I thought it doesn't need user and password.
<connectionStrings>
<add name="HRISContext"
connectionString="data source=.;initial catalog=BPSDEMO;Pooling=false;persist security info=True;user id=;password=;MultipleActiveResultSets=True;App=EntityFramework"
providerName="System.Data.SqlClient" />
</connectionStrings>
Upvotes: 0
Views: 4952
Reputation: 754478
If you want to use Windows authentication, then yes, you must not include any user id
and pwd
in your connection string - just remove those completely. But you must include the Integrated Security=SSPI
setting instead.
Try this:
<connectionStrings>
<add name="HRISContext"
connectionString="data source=.;initial catalog=BPSDEMO;Integrated Security=SSPI;MultipleActiveResultSets=True;Pooling=false;persist security info=True;App=EntityFramework"
providerName="System.Data.SqlClient" />
</connectionStrings>
Upvotes: 1