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

List the 4 common ado.net namespaces?

699


Explain the basic use of "dataview" and explain its methods.

533


What is meant by ‘transaction’ in a database and what are the ‘properties of transaction’?

535


Which database is the ado.net sql connection object designed for?

597


What are all the commands used with Data Adapter?

518






What providers does Ado.net uses?

579


What is linq and entity framework?

517


What is csdl entity framework?

557


What is serialization and de-serialization in .net? How can we serialize the dataset object?

520


What are the ado.net connection pooling parameters?

463


What is the current version of entity framework?

487


Which database is the ado.net?

500


What are ado.net objects?

531


What is the significance of CommandBehavior.CloseConnection ?

575


What is data relation?

504