V
Vicky via DotNetMonster.com
HI,
I found some sample code in .net documentation, and want to run it in
console application.
I am not sure how to call it in Main, could anyone help.
Thanks!
______________________________________________________________________
public void ReadMyData(string myConnString)
{
string mySelectQuery = "SELECT OrderID, CustomerID FROM Orders";
SqlConnection myConnection = new SqlConnection(myConnString);
SqlCommand myCommand = new SqlCommand(mySelectQuery,myConnection);
myConnection.Open();
SqlDataReader myReader;
myReader = myCommand.ExecuteReader();
// Always call Read before accessing data.
while (myReader.Read())
{
Console.WriteLine(myReader.GetInt32(0) + ", " + myReader.GetString(1));
}
// always call Close when done reading.
myReader.Close();
// Close the connection when done with it.
myConnection.Close();
}
__________________________________________________________________________
I found some sample code in .net documentation, and want to run it in
console application.
I am not sure how to call it in Main, could anyone help.
Thanks!
______________________________________________________________________
public void ReadMyData(string myConnString)
{
string mySelectQuery = "SELECT OrderID, CustomerID FROM Orders";
SqlConnection myConnection = new SqlConnection(myConnString);
SqlCommand myCommand = new SqlCommand(mySelectQuery,myConnection);
myConnection.Open();
SqlDataReader myReader;
myReader = myCommand.ExecuteReader();
// Always call Read before accessing data.
while (myReader.Read())
{
Console.WriteLine(myReader.GetInt32(0) + ", " + myReader.GetString(1));
}
// always call Close when done reading.
myReader.Close();
// Close the connection when done with it.
myConnection.Close();
}
__________________________________________________________________________