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 the executescalar method?
Why is stored procedure used in ado.net?
What are the different ado.net namespaces are available in .net?
What is ado.net and its features?
What provider ado.net use by default? Explain the role of data provider in ado.net?
What are all the different authentication techniques used to connect to MS SQL Server?
Which parameter of ConnectionString is used to specify the name of the database?
How do you connect to sql server database without using sqlclient?
how to create a quiz software using 4 options to answer and how to check with answers in the database and award marks....
Which ado.net object is very fast in getting data from the database?
What is a serialized object?
How do you merge 2 datasets into the third dataset in a simple manner?
What is ole access?
differences between ADO and ADO.NET
Explain what are acid properties?