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(stri ng myConnString)
{
string mySelectQuery = "SELECT OrderID, CustomerID FROM Orders";
SqlConnection myConnection = new SqlConnection(m yConnString);
SqlCommand myCommand = new SqlCommand(mySe lectQuery,myCon nection);
myConnection.Op en();
SqlDataReader myReader;
myReader = myCommand.Execu teReader();
// Always call Read before accessing data.
while (myReader.Read( ))
{
Console.WriteLi ne(myReader.Get Int32(0) + ", " + myReader.GetStr ing(1));
}
// always call Close when done reading.
myReader.Close( );
// Close the connection when done with it.
myConnection.Cl ose();
}
_______________ _______________ _______________ _______________ ______________
--
Message posted via http://www.dotnetmonster.com
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(stri ng myConnString)
{
string mySelectQuery = "SELECT OrderID, CustomerID FROM Orders";
SqlConnection myConnection = new SqlConnection(m yConnString);
SqlCommand myCommand = new SqlCommand(mySe lectQuery,myCon nection);
myConnection.Op en();
SqlDataReader myReader;
myReader = myCommand.Execu teReader();
// Always call Read before accessing data.
while (myReader.Read( ))
{
Console.WriteLi ne(myReader.Get Int32(0) + ", " + myReader.GetStr ing(1));
}
// always call Close when done reading.
myReader.Close( );
// Close the connection when done with it.
myConnection.Cl ose();
}
_______________ _______________ _______________ _______________ ______________
--
Message posted via http://www.dotnetmonster.com
Comment