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
What is the difference between dataset and datatable?
How can I retrieve two tables of data at a time by using data reader?
Explain the basic use of "dataview" and explain its methods.
Explain how can we load multiple tables in to dataset?
What is the difference between typed and untyped dataset?
Explain the different row versions available in table?
What are the parameters that control most of connection pooling behaviours?
Compare Data Reader & Dataset in ado.net?
How to Read, Add, Update and Delete record in Entity Framework ?
What does ado stand for?
What is adodb dll?
What is the role of clr?
What are the objects of ado.net?
How can we save all data from dataset?
How to create data relations?