using System; using System.Data; using MySql.Data.MySqlClient; class MainClass { public static void Main() { // Code to connect with database and create a dataset // and fill the dataset with the data in the table "tblUno" -- MySqlConnection myConn = new MySqlConnection( "user id=griv; password=andromeda; database=infraestructura; server=localhost"); MySqlCommand myCommand = new MySqlCommand("select * from tblUno", myConn); MySqlDataAdapter myDA = new MySqlDataAdapter(myCommand); DataSet myDS = new DataSet(); myDA.Fill(myDS, "dsUno"); // Code to add a row to the table dsUno in the dataset "dsUno" -- DataRow myRow = myDS.Tables["dsUno"].NewRow(); myRow["cCod"] = "ABC01"; myRow["cDenom"] = "Machine 1"; myDS.Tables["dsUno"].Rows.Add(myRow); // Code to verify that the former code had success -- foreach (DataColumn column in myDS.Tables["dsUno"].Columns) Console.WriteLine("{0}", column.Caption); foreach(DataTable myTable in myDS.Tables){ foreach(DataRow myRenglon in myTable.Rows){ foreach (DataColumn myColumn in myTable.Columns) Console.WriteLine(myRenglon[myColumn]); } } // Code to update the table "tblUno" with "dsUno" -- MySqlCommandBuilder mBuild = new MySqlCommandBuilder(myDA); myDA.Update(myDS, "dsUno"); } }It compiles without errors but when it runs, it sends the message shown bellow indicating a big
cCod cDenom ABC01 Machine 1 Unhandled Exception: System.InvalidOperationException: Connection must be valid and open at MySql.Data.MySqlClient.MySqlCommand.CheckState() at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior ) at MySql.Data.MySqlClient.MySqlCommandBuilder.GenerateSchema() at MySql.Data.MySqlClient.MySqlCommandBuilder.OnRowUpdating(Object sender, My SqlRowUpdatingEventArgs args) at MySql.Data.MySqlClient.MySqlDataAdapter.OnRowUpdating(RowUpdatingEventArgs value) at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMappi ng tableMapping) at System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable) at ManejoDatos.uno() in c:\aplics\estudio\dotnet\cnnet_adonet\Main.cs:line 54 at MainClass.Main() in c:\aplics\estudio\dotnet\cnnet_adonet\Main.cs:line 15 Press any key to continue . . .I will appreciate any kind of help to discover where am I wrong.