Click here to Skip to main content
15,891,777 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All
how can make sql connection string,any body help me,i m new in sql,i want to connect my asp.net page to sql-sever database
any body define step by step
Posted

ConnectionStrings.com is an awesome site for information on stuff like this.
 
Share this answer
 
Comments
[no name] 11-May-11 9:48am    
really this is an awesome site. my 4
Аslam Iqbal 11-May-11 10:22am    
my 5
Espen Harlinn 11-May-11 14:00pm    
Good link, my 5
 
Share this answer
 
If you look in the View menu of Visual Studio, you will find "Solution Explorer".
Look at this pane, and it will list all the Databases you can connect to.
Right click on the database you want, and select "Properties".
Look at the Properties pane and you will find "Connection String". You can copy and paste this into you app, or into your web.config file.
 
Share this answer
 
First you need to edit your 'web.config'. This file should look something like below:-


XML
<?xml version="1.0"?>
<configuration>
<connectionStrings>
  <add name="ConnectionString" connectionString="Data Source=servername;Initial
Catalog=databasename;Persist Security Info=True;User Id=username;Password=password;"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
  <customErrors mode="Off"/>
</system.web>
</configuration>


Then in your asp.net vb file use the below:-
Then the below is where you link to the connection string in the 'web.config' file:-
SQLConnection MyConnection = default(SQLConnection);
MyConnection = new SqlConnection();
MyConnection.ConnectionString = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString;


I hope this will help you.
 
Share this answer
 
Comments
[no name] 11-May-11 9:47am    
nice one.

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