View Single Post
  #1  
Old 11-05-2002, 10:36 AM
mByte
Hill Giant
 
Join Date: Feb 2002
Posts: 206
Default mySql connection?

Does anybody know how to pull a record out of a database in C#?

I know how to access the database in php and in vp.net but I cannot get this code to work.

This code opens the database but I cannot pull information out with objDR.ExecuteReader().

anyhelp would be cool


MySqlConnection objConn;
MySqlCommand objCmd;
MySqlDataReader objDR;
string sqlQuery, objConnStr;
//int id;

objConnStr = "Data source=localhost;database=eq311;" +
"user id=sa;password=sa;command logging=false;";

objConn = new MySqlConnection(objConnStr);
objConn.Open();

sqlQuery = "Select * from items";

objCmd = new MySqlCommand();

objCmd.CommandType = CommandType.Text;
objCmd.CommandTimeout=30;
objCmd.CommandText=sqlQuery;
objCmd.Connection=objConn;

label1.Text = objConn.State.ToString();
__________________
mByte
Reply With Quote