oledb exception

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shardul D
    New Member
    • Mar 2009
    • 2

    oledb exception

    Code:
    Private Sub CustomersBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CustomersBindingNavigatorSaveItem.Click
            Me.Validate()
            Me.CustomersBindingSource.EndEdit()
            Me.TableAdapterManager.UpdateAll(Me.payrollDataSet)
    for last line i am getting error as
    "An INSERT INTO query cannot contain a multi-valued field."
    i got this exception while trying to save record in access file.
    how to handle this?
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    Uh, uh, Let me guess... Someone who actually knows databases tell us if we are right...

    The error says that you can't send a multi-value field to an 'insert' command.
    The line looks like "dataset" is being sent into the 'insert' command.
    I would guess that 'dataset' is an entire set of data and not just one item.
    So I'm guessing the fix is to send the data one field at a time and not an entire dataset at one go.

    Comment

    • shardul D
      New Member
      • Mar 2009
      • 2

      #3
      there are at least 27 fields . do i have to send data for each field individually?

      Comment

      • tlhintoq
        Recognized Expert Specialist
        • Mar 2008
        • 3532

        #4
        I wasn't being a smart alec when I said I was guessing and hoping someone with more DB experience than myself would tell us both if my guess was write or wrong. I just tried to 'decode' the error message and relate it to the code you provided into something that *seemed* reasonable.

        I would at least try sending a couple fields one at a time and see if that works. If it does, then write in the other 25.

        Comment

        • Stewart Ross
          Recognized Expert Moderator Specialist
          • Feb 2008
          • 2545

          #5
          Mmm, we'd need to know a lot more about what is going underneath your dataset to really answer this one. Your tableadapter code as posted appears OK, according to the stuff I've seen on MSDN about it (as at this link), but only you can know if the dataset you are feeding to the updateall command meets the requirements for related tables specified for use with the tableadapterman ager component in visual studio.

          SQL's 'INSERT INTO' commands can insert many fields into a table simultaneously; 27 fields as you mention is not a problem. However, all INSERT INTO statements list the individual fields or field values, like this:

          INSERT INTO sometable (f1, f2, f3...fn) VALUES v1, v2, v3...vn

          The error message you quote is about multi-valued fields. I don't know the context in which this is arising, but the immediate question for me is are you trying to use an array somewhere as a single value in your updates? Or some other structured variant or object which is not a one-one match for your existing fields?

          Table fields in general can only contain simple types. If the data you are trying to insert is of some kind of compound type (such as an array or a user-defined data type) you will need to extract the individual components out of the compound type into individual fields in the relevant database table. But I'm guessing about this too, because the cause of your error is not at all clear when there is no context in your post to help us...

          -Stewart

          Comment

          Working...