using MySql.Data;
using MySql.Data.MySqlClient;
-----------------------------------
public Form1()
{
InitializeComponent();
}
string ConString = "Server=127.0.0.1;Database=r506;Uid=root;ConvertZeroDateTime=True;";
private void Form1_Load(object sender, EventArgs e)
{
MySqlConnection cnn = new MySqlConnection(ConString);
try
{
cnn.Open();
//MessageBox.Show("Connection Open ! ");
StatusLabel1.Text = "Connected !!";
StatusLabel1.ForeColor = Color.Green;
}
catch (Exception ex)
{
// MessageBox.Show("Can not open connection ! " + ex.Message);
StatusLabel1.Text = "UnConnected !!";
StatusLabel1.ForeColor = Color.Red;
}
finally
{
cnn.Close();
}
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น