Answer Posted / nitin kumar
Steps for 1. Using a SqlConnection
// Fully Commented Code
using System;
using System.Data;
using System.Data.SqlClient;
class SqlConnectionDemo
{
static void Main()
{
// 1. Instantiate the connection
SqlConnection conn = new SqlConnection(
"Data Source=(local);Initial
Catalog=Northwind;Integrated Security=SSPI");
SqlDataReader rdr = null;
try
{
// 2. Open the connection
conn.Open();
// 3. Pass the connection to a command object
SqlCommand cmd = new SqlCommand("select * from
Customers", conn);
//
// 4. Use the connection
//
// get query results
rdr = cmd.ExecuteReader();
// print the CustomerID of each record
while (rdr.Read())
{
Console.WriteLine(rdr[0]);
}
}
finally
{
// close the reader
if (rdr != null)
{
rdr.Close();
}
// 5. Close the connection
if (conn != null)
{
conn.Close();
}
}
}
}
| Is This Answer Correct ? | 7 Yes | 0 No |
Post New Answer View All Answers
What are uri parameters?
When we use cookie less session? Explain its working?
Explain how asp.net different from asp?
is there any third party tools are using in .net technologies? what are there ? give me the brief introduction?
How can you ensure a permanent cookie?
Which asp.net objects encapsulate the state of the client and the browser?
What is viewstate parameter?
Explain what is event bubbling?
What are validator? Name the validation controls in asp.net? How do you disable them?
What is the equivalent of date() and time() in asp.net?
Explain the role of global.asax?
What is page request in asp.net?
What is Web API Routing?
benefits of migration from asp to asp.net hi frnds, i have to give presentation to a client about how useful would be migrating their project from asp to asp.net .plz give me some points which i should incorporate in my ppt thanks
What does asp in asp.net stand for?