Sequence to connect and retrieve data from database useig
dataset ?
Answer Posted / pushpendra singh
step 1---// Connection creation using Connection string
to connect SQL database
SqlConnection conn=new SqlConnection("data
source=server_name;initial catalog=database_name;integrated
security=sspi");
conn.Open();
step2----execute command using SqlCommand Class.
SqlCommand cmd=new SqlCommand("select * from asd",conn);
DataSet ds=new DataSet();
SqlDataAdapter da=new DataAdapter();
da.SelectCommand=cmd;
//insert data from dataadapter to dataset
da.Fill(ds);
dataGridView1.DataSource=ds.Tables[0];
conn.Close();
| Is This Answer Correct ? | 1 Yes | 2 No |
Post New Answer View All Answers
What is the difference between executequery and executenonquery?
What is Dataset Object?
What is the current version of entity framework?
Is datareader faster than datatable?
What is data relation?
What is difference between datareader and dataadapter?
Does executenonquery return a value?
How will you fill the gridview by using datatable object at runtime?
What is ado.net architecture?
What is disconnected scenario in entity framework?
What is the use of SqlCommand object?
What is DataRowCollection?
How do I delete a row from a DataTable?
Give few examples of datareader that is used in different dataproviders.
What is data adapter in ado.net with example?