ODBC Dataadapter - Error HY007 on update!
-
C# .NET 1.1 I am using a ADO.NET Dataset containing of 2 tables... The tables are in a master(Table1)->detail(Table2) relationship and I use 2 Odbc Dataadapters (daTable1 and daTable2) to fill and update the tables... -- MyDataSet dataSet = new MyDataSet (); daTable1.Fill(dataSet); daTable2.Fill(dataSet); -- This works as expected and I use the dataset to change/insert some data. Now I am trying to update the database with the following code: -- if (dataSet.Table2.GetChanges(DataRowState.Deleted)!=null) { daTable2.Update(dataSet.Table2.GetChanges(DataRowState.Deleted)); } if (dataSet.Table1.GetChanges(DataRowState.Deleted)!=null) { daTable1.Update(dataSet.Table1.GetChanges(DataRowState.Deleted)); } if (dataSet.Table1.GetChanges(DataRowState.Modified)!=null) { daTable1.Update(dataSet.Table1.GetChanges(DataRowState.Modified)); } if (dataSet.Table2.GetChanges(DataRowState.Modified)!=null) { daTable2.Update(dataSet.Table2.GetChanges(DataRowState.Modified)); } if (dataSet.Table1.GetChanges(DataRowState.Added)!=null) { daTable1.Update(dataSet.Table1.GetChanges(DataRowState.Added)); } if (dataSet.Table2.GetChanges(DataRowState.Added)!=null) { daTable2.Update(dataSet.Table2.GetChanges(DataRowState.Added)); } -- I could do the same with daTable1.Update(dataSet.Table1) daTable2.Update(dataSet.Table2) but I don't want to rely on cascading updates / deletes... Anyway when both tables are effected I get the following OdbcException when calling the second Update method: OdbcException ( ERROR [HY007] [Microsoft][ODBC SQL Server Driver]Associated statement is not prepared) --- I really don't know why this happens and I couldn't find any information on the net. I would really appreciate any help! Thanks in advance Pakl
-
C# .NET 1.1 I am using a ADO.NET Dataset containing of 2 tables... The tables are in a master(Table1)->detail(Table2) relationship and I use 2 Odbc Dataadapters (daTable1 and daTable2) to fill and update the tables... -- MyDataSet dataSet = new MyDataSet (); daTable1.Fill(dataSet); daTable2.Fill(dataSet); -- This works as expected and I use the dataset to change/insert some data. Now I am trying to update the database with the following code: -- if (dataSet.Table2.GetChanges(DataRowState.Deleted)!=null) { daTable2.Update(dataSet.Table2.GetChanges(DataRowState.Deleted)); } if (dataSet.Table1.GetChanges(DataRowState.Deleted)!=null) { daTable1.Update(dataSet.Table1.GetChanges(DataRowState.Deleted)); } if (dataSet.Table1.GetChanges(DataRowState.Modified)!=null) { daTable1.Update(dataSet.Table1.GetChanges(DataRowState.Modified)); } if (dataSet.Table2.GetChanges(DataRowState.Modified)!=null) { daTable2.Update(dataSet.Table2.GetChanges(DataRowState.Modified)); } if (dataSet.Table1.GetChanges(DataRowState.Added)!=null) { daTable1.Update(dataSet.Table1.GetChanges(DataRowState.Added)); } if (dataSet.Table2.GetChanges(DataRowState.Added)!=null) { daTable2.Update(dataSet.Table2.GetChanges(DataRowState.Added)); } -- I could do the same with daTable1.Update(dataSet.Table1) daTable2.Update(dataSet.Table2) but I don't want to rely on cascading updates / deletes... Anyway when both tables are effected I get the following OdbcException when calling the second Update method: OdbcException ( ERROR [HY007] [Microsoft][ODBC SQL Server Driver]Associated statement is not prepared) --- I really don't know why this happens and I couldn't find any information on the net. I would really appreciate any help! Thanks in advance Pakl
You need to specify the update command that the dataApdater should use i.e. the UpdateCommand.
-
You need to specify the update command that the dataApdater should use i.e. the UpdateCommand.
Thanks... Yes I know, I forgot to mention that I generate the dataadapters .... and I didn't post the code, because it is very very long. The UpdateCommand is valid. And it works if only one of the tables has changed...