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 a column variable?
Can you explain how to enable and disable connection pooling?
Define Execute Scalar?
What is csdl entity framework?
What are the ado.net objects?
How to work with disconnected data - the dataset and sqldataadapter?
What are basic methods of dataadapter?
If a table contains 20000 records. In a page at each time 100 records to be displayed.
Explain ODP.net
What is a datareader object?
How does ado.net work?
Is it possible to edit data in Repeater control?
How can I retrieve two tables of data at a time by using data reader?
What is difference between ado.net and asp net?
What are the methods of XML dataset object?