Click here to Skip to main content
15,900,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to attach sql server to asp.net?
Posted

You have to do it through the web.config

Add the following, and read more about how to invoke database calls from your web app.


XML
<connectionStrings>
<add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
</connectionStrings>


Read the following for more details.

http://msdn.microsoft.com/en-us/library/ms178411.aspx
 
Share this answer
 
v2
Comments
fjdiewornncalwe 21-Mar-11 15:03pm    
Although it is the preferred way to do it, it is not the way "you have to do it". There are many ways solve this problem, but especially for beginners, this is the suggested way. (+5).
CodingLover 22-Mar-11 1:29am    
I agreed. This is a very basic step to get a start. In most of the commercial applications the web.config plays a major role and need lots of advance stuff on it.
You can get the solution just by searching in google itself.

Try this[^].
or
how to connect sql database to asp.net[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900