According To The Database We Selected , There Are Different Ways To Give <connectionStrings> In Web.Config File In ASP.NET
If We Taken The Database By Right-Click On “App_Data“ Folder In ‘Solution Explorer’ Of Visual Studio And Click On “Add New Item” And Selected The “SQL Server Database (i.e., Database.mdf)”
Then The Connection String In Web.ConfigFile Should Be As:
<connectionStrings>
<addname="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient"/>
</connectionStrings>
Or
If We Create The Database Using “Microsoft SQL Server Management Studio”, To Connect To The Database The Connection String In Web.Config File Should Be As:
<connectionStrings>
<addname=" ConnectionString" connectionString="user id=sa;database=Your Database Name;data source=Your Server Name;password=Your Password;integrated security=SSPI;Persist Security Info=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
For Example:
<connectionStrings>
<addname=" ConnectionString" connectionString="user id=sa;database=CountryNames;data source=RACK-I3;password=1234567;integrated security=SSPI;Persist Security Info=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
No comments:
Post a Comment
Note: only a member of this blog may post a comment.