Has anyone successfully used MySQL with C#?
I'm having problems using the Update command
Here is the code snippet. I am able to connect to the database. However when I try to update the database with the changes in the dataset I get the following error:
An unhandled exception of type 'System.Invalid OperationExcept ion' occurred in system.data.dll
Additional information: Dynamic SQL generation is not supported against a SelectCommand that does not return any base table information.
public void setupConnection ()
{
conString="Prov ider=MySQLProv; Data Source=wedtest; SERVER=localhos t;DB=wedtest;UI D=admin;PWD=pas sword;PORT=3306 ";
myConnection=ne w OleDbConnection (conString) ;
string_sql="sel ect * from Budget";
myDataSet = new DataSet();
myConnection.Op en() ;
if(myConnection .State==Connect ionState.Open)
{
Console.WriteLi ne("Connection made");
}
myOleDbAdapter = new OleDbDataAdapte r(string_sql,my Connection);
myOleDbAdapter. Fill(myDataSet, "Budget") ;
dataGrid1.DataS ource = myDataSet.Defau ltViewManager;
myCommandBuilde r=new OleDbCommandBui lder(myOleDbAda pter);
}
public void updateRecord()
{
// Get all of the updated rows and update the datastore
updatedRows = myDataSet.GetCh anges(System.Da ta.DataRowState .Modified);
if (((updatedRows) != (null)))
{
myOleDbAdapter. Update(updatedR ows,"Budget");
}
}
An unhandled exception of type 'System.Invalid OperationExcept ion' occurred in system.data.dll
Additional information: Dynamic SQL generation is not supported against a SelectCommand that does not return any base table information.
I'm having problems using the Update command
Here is the code snippet. I am able to connect to the database. However when I try to update the database with the changes in the dataset I get the following error:
An unhandled exception of type 'System.Invalid OperationExcept ion' occurred in system.data.dll
Additional information: Dynamic SQL generation is not supported against a SelectCommand that does not return any base table information.
public void setupConnection ()
{
conString="Prov ider=MySQLProv; Data Source=wedtest; SERVER=localhos t;DB=wedtest;UI D=admin;PWD=pas sword;PORT=3306 ";
myConnection=ne w OleDbConnection (conString) ;
string_sql="sel ect * from Budget";
myDataSet = new DataSet();
myConnection.Op en() ;
if(myConnection .State==Connect ionState.Open)
{
Console.WriteLi ne("Connection made");
}
myOleDbAdapter = new OleDbDataAdapte r(string_sql,my Connection);
myOleDbAdapter. Fill(myDataSet, "Budget") ;
dataGrid1.DataS ource = myDataSet.Defau ltViewManager;
myCommandBuilde r=new OleDbCommandBui lder(myOleDbAda pter);
}
public void updateRecord()
{
// Get all of the updated rows and update the datastore
updatedRows = myDataSet.GetCh anges(System.Da ta.DataRowState .Modified);
if (((updatedRows) != (null)))
{
myOleDbAdapter. Update(updatedR ows,"Budget");
}
}
An unhandled exception of type 'System.Invalid OperationExcept ion' occurred in system.data.dll
Additional information: Dynamic SQL generation is not supported against a SelectCommand that does not return any base table information.
Comment