Results 1 to 3 of 3

Thread: OLE DB operation generated errors

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2004
    Location
    Chennai, India
    Posts
    3

    Lightbulb OLE DB operation generated errors

    I am getting the following err messages when inserting a new record into MS Access table.

    Err.Number : -2147217887
    Err.Decription : Multiple-step OLE DB operation generated errors.
    Check each OLE DB status value, if available. No
    work was done.

    table design :
    ----------------
    Name(text)
    Addr1(text)
    addr2(text)
    place(text)
    Cell(text)

    I have not given any values for the fileds : Addr1,Addr2, Place, Cell when inserting into access table.

    Note : Except the name field the settings of the other field are
    “Required = No”
    “Allow Zero Length=No”


    Code :
    -----------------------------------------------------------------------------
    rs.Open “addr”, cn, adOpenDynamic, adLockOptimistic
    rs.AddNew
    rs!Name = txtName.Text
    rs!addr1 = txtAddr1.Text
    On Error GoTo errHandler
    rs!addr2 = txtAddr2.Text (err in this statement)
    rs!place = txtPlace.Text
    rs!cell = txtCell.Text
    rs.Update
    rs.Close

    -----------------------------------------------------------------------------
    any tips?

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    I have not given any values for the fileds : Addr1,Addr2, Place, Cell when inserting into access table
    “Allow Zero Length=No”
    You don't see the conflict between the two statements above?

    Allow Zero Length=No - means you cannot enter an empty space, ie "", which is what a text box contains if it is blank.

    To fix the problem, allow zero length strings or check if the textbox is empty and if so bypass the statement (ie the database value will be Null).

    VB Code:
    1. If Len(Trim$(txtAddr2.Text)) > 0 Then
    2.    rs!addr2 = txtAddr2.Text
    3. End if
    4. If Len(Trim$(txtPlace.Text)) > 0 Then
    5.     rs!place = txtPlace.Text
    6. End if

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2004
    Location
    Chennai, India
    Posts
    3

    Thumbs up

    interesting code
    thaks 4 the tip

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width