S
Sig
How to I detect reference library is in place. If not, it will prompt
dll not found and terminate the program?
Following is my sample program:
using System;
using MySql.Data.MySqlClient;
class mysql
{
public static void Main()
{
try
{
MySqlConnection con = new MySqlConnection
("server=localhost;database=test;uid=root;pwd=;");
MySqlCommand cmd = new MySqlCommand();
MySqlDataReader rdr;
con.Open();
cmd.Connection = con;
cmd.CommandText = "SHOW TABLES";
rdr = cmd.ExecuteReader();
while (rdr.Read())
{
Console.WriteLine(rdr[0].ToString());
}
Console.WriteLine();
rdr.Close();
con.Close();
}
catch(Exception e)
{
Console.WriteLine(e.Message);
}
}
}
Compiling options:
csc /optimize /nologo /target:exe /reference:MySql.Data.dll /
out:mysql.exe mysql.cs
If I were to rename or remove the MySql.Data.dll file, then my program
will have error even though I already catch all exceptions.
So, how do I solve this problem?
Thanks a lot!
Sig
dll not found and terminate the program?
Following is my sample program:
using System;
using MySql.Data.MySqlClient;
class mysql
{
public static void Main()
{
try
{
MySqlConnection con = new MySqlConnection
("server=localhost;database=test;uid=root;pwd=;");
MySqlCommand cmd = new MySqlCommand();
MySqlDataReader rdr;
con.Open();
cmd.Connection = con;
cmd.CommandText = "SHOW TABLES";
rdr = cmd.ExecuteReader();
while (rdr.Read())
{
Console.WriteLine(rdr[0].ToString());
}
Console.WriteLine();
rdr.Close();
con.Close();
}
catch(Exception e)
{
Console.WriteLine(e.Message);
}
}
}
Compiling options:
csc /optimize /nologo /target:exe /reference:MySql.Data.dll /
out:mysql.exe mysql.cs
If I were to rename or remove the MySql.Data.dll file, then my program
will have error even though I already catch all exceptions.
So, how do I solve this problem?
Thanks a lot!
Sig