Can anyone make for me an example code to select column bl1_xfg from database zgloszenia server 123.456.789.123, user: test and pass asdqwe123qweasd. I'm using Spark library on Command Line Application runnig by mono on Debian Lenny.
using System;
using System.Data;
using MySql.Data.MySqlClient;
public class Test
{
public static void Main(string[] args)
{
string connectionString =
"Server=123.456.789.123;" +
"Database=zgloszenia;" +
"User ID=test;" +
"Password=asdqwe123qweasd;" +
"Pooling=false";
IDbConnection dbcon;
dbcon = new MySqlConnection(connectionString);
dbcon.Open();
IDbCommand dbcmd = dbcon.CreateCommand();
string sql =
"SELECT bl1_xfg FROM tablename";
dbcmd.CommandText = sql;
IDataReader reader = dbcmd.ExecuteReader();
while(reader.Read()) {
string bl1_xfg = (string) reader["bl1_xfg"];
Console.WriteLine("bl1_xfg: " + bl1_xfg);
}
// clean up
reader.Close();
reader = null;
dbcmd.Dispose();
dbcmd = null;
dbcon.Close();
dbcon = null;
}
}