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 fill method in ado.net?
What are different layers of ADO.Net?
What are the different execute methods of Ado.Net?
What is sqlconnection and sqlcommand?
What is maximum pool size in ado.net connection string?
What is XML serialization
How to generate a single aggregate?
How can we check that some changes have been made to dataset since it was loaded?
What is meant by ‘transaction’ in a database and what are the ‘properties of transaction’?
What is ole word?
Which method is used by command class to execute SQL statements that return single value?
What are the ado.net connection pooling parameters?
What is ado net stands for?
What is the difference between DataReader and DataSet in ADO.NET?
What is difference between entity framework and ado.net?