[Mono-devel-list] ByteFX mysql
Paul F. Johnson
paul at all-the-johnsons.co.uk
Mon Aug 8 10:05:38 EDT 2005
Hi,
> The message is 'Main.cs(4) error CS0246: The namespace `ByteFx.Data' can
> not be found (missing assembly reference?)'.
mcs filename.cs -r:ByteFX.Data
My sql and C# is really easy - have a look at this
using System;
using System.Data
using ByteFX.Data.MySqlClient;
public class mysqlc
{
public static void Main(string [] args)
{
if (args[0] == "")
{
Console.WriteLine("I need a search criteria");
return;
}
string connectionString = "Server=localhost;"+
"Database=<database_name>;"+
"User ID=<user_id>;"+
"Password=<password>;";
IDbConnection dbcon;
dbcon = new MySqlConnection(connectionString);
dbcon.Open();
IDbCommand dbcmd = dbcon.CreateCommand();
string sql = "SELECT * FROM <tablename> WHERE <search> LIKE
'%%"+args[0]+"%%%';"
dbcmd.CommandText = sql;
IDataReader reader = dbcmd.ExecuteReader();
while (reader.Read())
{
// do what you have to here
}
reader.Close();
reader = null;
dbcmd.Dispose();
dbcmd = null;
dbcon.Close();
dbcon = null;
}
}
--
"Logic, my dear Zoe, is merely the ability to be wrong with authority" - Dr
Who
More information about the Mono-devel-list
mailing list