Hi,
I need to connect to a MySQL database via C# express 2008. I think I got the code right apart from the connection string. I obtained this code from a forum but the connection string was for SQLExpress 2005. Can someone please help me on how can I fix this? Here is the code with the SQL Express connection string:
//string connectionString = "Driver={SQL Native Client}; Server=localhost\\sqlexpress;" + "Database=oshahsdb;Trusted_Connection=yes;";
using (OdbcConnection odbcCon = new OdbcConnection(connectionString))
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);
this.dataGridView1.DataSource = ds.Tables[0];
}
I also need to add a username and password to the connection string.
Any help would be greatly appreciated.
Many thanks in advance.
Chris