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


Please Help Members By Posting Answers For Below Questions

Which object of ado contains datarow datacolumn collection?

718


What is the difference between Optimistic and Pessimistic locking?

766


What is executequery?

704


Why ca not we use multiple inheritance and garbage collector paralelly in .net?

785


Is bulk insert faster than insert?

700


Describe briefly an ADO.NET Dataset ?

768


What is Data Provider?

820


What are the types of databinding?

742


How to copy the contents from one table to another table and how to delete the source table in ado.net?

770


What provider ado.net use by default? Explain the role of data provider in ado.net?

746


Why edit is not possible in repeater?

721


What is difference between datatable and dataset?

768


What is method to get XML and schema from Dataset? getXML() and get Schema ()

766


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

777


What is bubbled event?

736