Write steps of retrieving data using ado.net ?

Answer Posted / senthil kumar

we can use two ways to retrieve the data from database
1 -> data reader
2 -> data adapter

when you use datareader
create connection object and open the connection
SqlCommand cmd = new SqlCommand(sql,con);
cmd.CommandType = CommandType.Text;
SqlDataReader sread = cmd.ExecuteReader();
while(sread.Read())
{
String data1 = sread.GetString(0);
int data2 = sread.GetValue(1);
String data3 = sread.GetString(2);
}

when u use the dataadapter

create the connection and open
SqlDataAdapter sda = new SqlDataAdapter(sql,con);
DataSet ds = new DataSet();
sda.Fill(ds,"customer");

then use can get the data in row wise or directly assign
the data to the controls through datasource.

i think its enough.If i did any mistake correct me.

Is This Answer Correct ?    13 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you update a dataset in ado.net?

737


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

740


What are the Features and disadvantages of dataset

746


Explain how to find the given query is optimised one or not?

697


What is a string variable?

639


What are the Features of a dataset

852


What is connected architecture in ado.net?

680


How can we load multiple tables in to dataset?

782


What is ole in excel?

688


Where is adodb dll located?

705


If a table contains 20000 records. In a page at each time 100 records to be displayed.

686


Explain why canot we use multiple inheritance and garbage collector paralelly in .net?

774


Can you explain how to enable and disable connection pooling?

701


What do you know about ado.net's objects?

688


What are the essential features of ado.net?

702