I
Iain
Hi
Is it possible to get Visual Studio C# Express (beta 2) connecting to a
MySQL database?
TIA
Iain
Is it possible to get Visual Studio C# Express (beta 2) connecting to a
MySQL database?
TIA
Iain
scott blood said:Iain,
Unfortunatly you cannot visually connect to MySQL through C# Express, i
dont know why, i think this is just one of the limitations of C# Express.
However, you can use ODBC to connect to MySQL through code, so long as you
know the ODBC Connection string to use. Please have a look at the
following code snippet.
using System.Data.Odbc;
using System.Data;
private void GetDataFromMySQL()
{
string connStr = "";
// i am not sure what the connection string for MySql would be, i think it
might "Provider=MySQLProv;Data Source=mydb;User
Id=UserName;Password=asdasd;"
using (OdbcConnection odbcCon = new OdbcConnection(connStr))
using (OdbcCommand odbcCom = new OdbcCommand("Select * From Product",
odbcCon))
using (OdbcDataAdapter odbcDA = new OdbcDataAdapter(odbcCom))
using (DataSet ds = new DataSet())
{
odbcCon.Open();
odbcDA.Fill(ds);
/** Now that we have it in a DataSet, we can do what you want with it:
f your controls...
**/
this.dataGridView1.DataSource = ds.Tables[0];
}
}
Hope this helps
Regards
Scott Blood
C# Developer
Iain said:Hi
Is it possible to get Visual Studio C# Express (beta 2) connecting to a
MySQL database?
TIA
Iain
However, you can use ODBC to connect to MySQL through code
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.