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 ole used for?
What is a datareader object?
Explain the different row versions available in table?
Explain About ado.net components/objects. Usage of data adapters and tell the steps to retrieve data.
Define ado.net?
What are different layers of ADO.Net?
What are the different layers of ado.net?
Which parameter of ConnectionString is used to specify the name of the database?
What are all features of ADO.Net?
Which provider is used to connect ms access, oracle, etc…?
Explain the DataAdapter.Update() and DataSetAcceptChanges() methods.
What is dao and ado?
What are the different namespaces used in the project to connect the database? What data providers available in .net to connect to database?
Which is better entity framework or ado.net?
What is acid in ado.net?