What are the steps in connecting to database ?

Answers were Sorted based on User's Feedback



What are the steps in connecting to database ?..

Answer / 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

What are the steps in connecting to database ?..

Answer / khalid

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

Using System.Data.SqlClient;

//connection
//If u provide uname & passwd to ur Database then this state //is true
SqlConnection con = new
SqlConnection("server=localhost;database=urDB_Name;uid=sa;pwd=;");
//else
SqlConnection con = new
SqlConnection("server=localhost;database=urDB_Name;");

con.Open();
if(con!=null)
msgbox("Connection sucessfully Done!");
else
msgbox("Sorry!Connection sucessfully is not Done!");

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More ADO.NET Interview Questions

What is meant by executenonquery?

0 Answers  


Why is ADO.NET serialization slower than ADO ?

0 Answers   NA,


What is a sqldataadapter?

0 Answers  


What are the three Ado objects?

6 Answers   Microsoft, StarSoft,


What is the maximum pool size in ado.net connection string?

0 Answers  






What is a datatable?

8 Answers   State Bank Of India SBI,


What is datacolumn and how it is used?

2 Answers  


What are the ado.net connection pooling parameters?

0 Answers  


What are two important objects of ADO.Net?

0 Answers  


What are the disadvantages of using datalist?

0 Answers  


how to keep track of index in listbox items.

2 Answers  


What is DataRowCollection?

0 Answers  


Categories