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 provider ado.net use by default? Explain the role of data provider in ado.net?

0 Answers  


What is ado and rdo?

0 Answers  


What is oledb connection?

0 Answers  


Describe datareader object of ado.net with example.

0 Answers  


What is ado rdo dao in visual basic?

0 Answers  






What is the role of the dataset object in ado.net?

0 Answers  


Explain the difference between ado and ado.net?

0 Answers  


How to add Primary key in DataSet

6 Answers  


What is the difference between connected and disconnected environment?

0 Answers  


What is acid in ado.net?

0 Answers  


how to create a quiz software using 4 options to answer and how to check with answers in the database and award marks....

1 Answers   Ford,


What is isolation?

0 Answers  


Categories