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
Define data access layer?
What is ado full form?
What is ado.net connection?
What is ado.net objects?
What is difference between ado and other data object?
Which name space is used to get assembly details?
What is the purpose of using adodb?
differance between ADO vs ADO.Net?
How can we load multiple tables in to dataset?
What is an example of ordinal data?
What are all components of ADO.Net data provider?
How to read data with the sqldatareader ?
What are the essential features of ado.net?
What is a non query?
What is ado.net and its architecture?