What is sequence of code in retrieving data from database ?
Answer Posted / senthil kumar
if you use sql server
SqlConnection con = new SqlConnection();
con.ConnectionString ="Data Source=servername;Initial
Catalog=databasename;";
con.Open();
String sql;
sql ="select * from tbl_tablename";
SqlCommand cmd = new SqlCommand(sql,con);
SqlDataReader reader;
reader = cmd.ExecuteReader();
while(reader.Read)
{
Console.WriteLine("Field1:"+read.GetString(0));
Console.WriteLine("Field1:"+read.GetString(1));
Console.WriteLine("Field1:"+read.GetValue(2));
}
con.Close();
}
| Is This Answer Correct ? | 9 Yes | 4 No |
Post New Answer View All Answers
Is entity framework better than ado.net?
Why do we need ado.net?
What is the difference between a datareader and a dataset?
What is the difference between oledb sql server and oledbdotnet provider?
What is bubbled event?
What are all the different methods under sqlcommand?
What is connected architecture in ado.net?
What is data access pattern?
What is dataset object? Explain the various objects in dataset.
What are the advantages using ado.net?
Explain the advantage of ADO.Net?
Explain the difference between ado and ado.net?
What are the important features of ado.net 2.0?
Explain executenonquery?
Which name space is used to get assembly details?