How to make databse connectivity in ASP.NET?

By November 9, 2011 ASP.NET
Please add the follwoing code in you sample.cs page.

Step 1 : Add Namspace “using System.Data.SqlClient;”

Step 2 : Make Sql connection.

SqlConnection con = new SqlConnection(“Server=You server name or comp name;
Database=Yourdatabasename;Trusted_Connectopn=True”);
SqlCommand cmd = new SqlCommand(“select * from Table name”);
con.Open();
DataSet ds = new DataSet(cmd,con);
SqlDataAdapter da = new SqlDataAdapter();
da.Fill(ds);
con.Close();

Leave a Reply

76 − 68 =

Open chat
💬 Need help?