Click here to Skip to main content
16,004,969 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to create a simple project with ASP.net and C#
I want to connect the database. how to do it in asp.net.The error will occured give the sqlconnection. which namespace will given

Please anyone can help for this problem

Thank you
Posted

Hi,

Use this namespace :
C#
using System.Data.SqlClient;


declare sql connection class:

C#
SqlConnection Con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["testConnectionString"].ToString());
Con.Open();


put this one on web.config file and set four parameters as per your sql server Data Source name, Initial Catalog, User ID and Password.

XML
<connectionStrings>
  <add name="testConnectionString" connectionString="Data Source=;Initial Catalog=;User ID=;Password=;
   providerName="System.Data.SqlClient" />
 </connectionStrings>
 
Share this answer
 
v2
please refer some pdf to learn more about asp.net, this namespace below which we use in code behind to connect...go thru tutorial pdf

using System.Data.SqlClient;
..
 
Share this answer
 
Hi,

Follow this side to learn asp.net and ado.net.

http://www.csharp-station.com/Tutorial.aspx[^]
http://www.csharp-station.com/Tutorials/AdoDotNet/Lesson01.aspx[^]

i think this is help to you............
 
Share this answer
 
 
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