|
Here is a sample script to be used to access a MySQL database using .Net. This requires the use of ""MySQLDriverCS"", wihch can be downloaded from source forge for free.
|
|
|
using MySQLDriverCS;
try
{
MySQLConnection con;
con = new MySQLConnection( new MySQLConnectionString("localhost",
"database",
"user",
"pass").AsString );
con.Open();
string sql = "SELECT * FROM Table";
MySQLCommand cmd = new MySQLCommand(sql,con);
MySQLDataReader reader = cmd.ExecuteReaderEx();
while(reader.Read())
{
Console.WriteLine( reader[0].ToString() );
}
reader.Close();
con.Close();
}
catch(Exception ee)
{
Console.WriteLine( ee.ToString() );
}
|