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
What is different between sqlcommand object and command behavior object?
Does executenonquery return a value?
What are different layers of ADO.Net?
What is ado full form?
What do you know about ado.net's objects?
What is a dynaset in access?
What is microsoft ole db provider for sql server?
What is full form of ado?
Which database is the ado.net sql connection object designed for?
What is ado net stands for?
What are the advantages of using datalist?
What provider ado.net use by default? Explain the role of data provider in ado.net?
What are the pre-requisites for connection pooling?
Name which operations can you not perform on an ado.net dataset?
What is the use of SqlCommand object?