hi I'm getting problem in the connection with mysql
this is my coding in a class can anyone please tell me how to open the connection.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;
namespace library_management_system
{
class Class1
{
}
public class database1
{
public string cnn = "server=127.0.0.1;user=root;database=library management system;port=3306;password=password;";
public string cmd;
public string da;
public string dr;
}
public class conn
{
database1 x = new database1();
MySqlConnection cnn1 = new MySqlConnection(cnn1.ConnectionString = x.cnn );
cnn1 .open();
MySqlCommand cmd = new MySqlCommand(x.cmd, cnn1);
}
}
Loading
SenthilkumarPosted May 3, 2012, 12:19 AM
Always you are advised to use the try catch to identify the error.
Because there may be an issue with the server or database name may be wrong.
See the samples of my sql connectivity.
http://www.codeproject.com/Articles/12300/An-ASP-NET-Application-Using-a-MySQL-Database
http://www.stardeveloper.com/articles/display.html?article=2003052201&page=1