Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. ODBC Dataadapter - Error HY007 on update!

ODBC Dataadapter - Error HY007 on update!

Scheduled Pinned Locked Moved C#
csharpdatabasehelpsql-serversysadmin
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Patrick Klug
    wrote on last edited by
    #1

    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

    G 1 Reply Last reply
    0
    • P Patrick Klug

      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

      G Offline
      G Offline
      Gavin Jeffrey
      wrote on last edited by
      #2

      You need to specify the update command that the dataApdater should use i.e. the UpdateCommand.

      P 1 Reply Last reply
      0
      • G Gavin Jeffrey

        You need to specify the update command that the dataApdater should use i.e. the UpdateCommand.

        P Offline
        P Offline
        Patrick Klug
        wrote on last edited by
        #3

        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...

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups