remote connection to mysql server in ubuntu using vc# installed in other system

am using mysql server installed in ubuntu and i made the the remote connection successful.Even though the connection was successful am not able to access mysql namespace in c#,as am novice to this mysql can some one help me in this regard how can i access that mysql namespace and provide me some sample to execute queries like connection string and filling dataset with adapter classes .....

can i able to make the connection string using adodb? how can i do this some one can help me please

thanks in advance
LVL 7
Maverick_CoolAsked:
Who is Participating?
 
mankowitzCommented:
Have you tried this?
MySql.Data.MySqlClient.MySqlConnection conn;
string myConnectionString;
    
myConnectionString = "server=127.0.0.1;uid=root;" +
    "pwd=12345;database=test;";
  
try
{
    conn = new MySql.Data.MySqlClient.MySqlConnection();
    conn.ConnectionString = myConnectionString;
    conn.Open();
}
catch (MySql.Data.MySqlClient.MySqlException ex)
{
    MessageBox.Show(ex.Message);
}

Open in new window

0
 
mankowitzCommented:
also, to import the namespace, you;d use

using MySql.Data.MySqlClient;
0
 
mankowitzCommented:
oops. you said adodb. open the db with oledb then do this
using System.Data;
using System.Data.OleDb; 
using ADODB;

string DBConnection = "xxxx"";
string SQL = "select title_id,title,type,price from ....";

//create ADODB Connection object
ADODB.Connection Conn=new ADODB.Connection();

//create ADODB Recordset object
ADODB.Recordset rs= new ADODB.Recordset();

//create OleDb Adapter object
OleDbDataAdapter daTitles=new OleDbDataAdapter();

// finally Dataset to store returned recordset
DataSet dsTitles=new DataSet("Authors");

//open connection with the string as above
Conn.Open(DBConnection,"","",-1); 

//execute the query specifying static sursor, batch optimistic locking 
rs.Open(SQL,DBConnection,ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockBatchOptimistic,1); 

//use the overloaded version of Fill method which takes recordset as parameter
daTitles.Fill(dsTitles,rs,"Tiltes"); 

//bind datagrid to dataset 
dataGridTitles.SetDataBinding(dsTitles,"Tiltes"); 

///close the connection
Conn.Close(); 
}

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.