What are the steps in connecting to database ?

Answer Posted / kalirajan

// Declare Namespace as ur Lang...
In c#

Using System.Data.SqlClient;

//connection

SqlConnection con = new
SqlConnection("server=localhost;database=Grid_Db;uid=sa;pwd=;");

con.Open();

SqlCommand cmd = new SqlCommand("select * from Gtid_Tbl",con);

SqlDataAdapter da = new SqlDataAdapter(cmd);

DataSet ds = new DataSet();

da.Fill(ds);

GridView1.DataSource = ds;
GridView1.DataBind();

Is This Answer Correct ?    6 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to create data relations?

548


What Is Difference Between Ado And Ado.net?

558


Explain the difference in record set and dataset?

488


What is the difference between executequery and executenonquery?

506


What are three methods for displaying data in a syncfusion datagrid

612






What is connected architecture in ado.net?

522


What does ole stand for in excel?

598


What are two types of transaction supported by ado.net?

533


What are typed and untyped dataset?

557


What is difference in record set and dataset?

534


How do you connect to sql server database without using sqlclient?

560


Is bulk insert faster than insert?

493


What is the default timeout specified for "sqlcommand.commandtimeout" property?

539


What are the advantages of ado.net?

509


How many major types of connection objects in ADO.NET?

589