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
Explain ODP.net
How to creating a SqlCommand Object?
Which is faster sqldataadapter and sqldatareader?
How do we use stored procedure in ADO.NET and how do we provide parameters to the stored procedures?
How can we perform transactions in .net?
What are the different row versions available in table?
What is aggregating data ?
What are the benefits of using of ADO.NET in .NET 4.0?
How do you update a dataset in ado.net?
Explain how to create dynamic gridview?
What are dataproviders?
Is entity framework better than ado.net?
Which object needs to be closed?
Explain why edit is not possible in repeater?
Some important instruction regarding ADO.NET connection string ?