Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

detail code for sql data connections?

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


Please Help Members By Posting Answers For Below Questions

What is the maximum number of classes that can be contained in one dll file?

1257


What is the difference between Classic ASP and ASP.Net?

1164


Is asp.net mvc front end or backend? : Asp.Net MVC

980


Explain different types of validators in asp.net?

1059


What are different types of authentication techniques that are used in connection strings to connect .net applications with microsoft sql server?

1060


Describe the diffeerence between inline and code behind - which is best in a loosely coupled solution?

1140


Explain the steps needed to be performed in order to create an animation in xaml?

1063


What is enableviewstate in asp net?

998


How do cookies work?

1037


i want to implement grid view value in paypal site. so how to create this code in asp.net with C#

1980


What is the difference between ldap and active directory?

1129


What is Dynamic Web and discuss its usage with the help of real life examples?

1092


What are the asp.net server side objects?

1021


What are the contents of cookie?

1149


What is the function of new view engine in asp.net? : asp.net mvc

1054