Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2009

    Unanswered: Need help in VB. Please help fast

    Hello guys,

    I am making a program in VB as frontend and Sql2000 as Backend.
    Now i have a form to add new employee in the database. There is a button on the form as Add. After filling all the fields in the form when the user clicks on Add it should be added in the Employee table in the database. This is the code that i am using to add the record:

    Private Sub add_Click()
    emp.Recordset.AddNew Array("emp_no", "f_name", "l_name", "designation", "emp_image"), Array(Val(Text1), Text2, Text3, Combo1.Text, strpath)
    End Sub
    Here 'emp' is name of the ADODC component. It is already connected to the database and to the employee table.
    Now when i run it and after entering records this is the error i get:

    Run-time error '-2147217887 (80040e21)':
    Multiple-step operations generated errors. Check each status value.
    I am stuck up and cant go ahead with my project.

    Please i request you to help me soon.

    Thanking you.

  2. #2
    Join Date
    Mar 2009
    Provided Answers: 15
    1) In order to figure out what's going wrong, you should try not to use Array(... ) but pass every argument individually, that way you can test on every value you pass to the method. Array() can yield to some strange and subtle errors and some unexpected results

    2) Explicitly reference the arguments and don't rely on implicit conversion: Me.Text2.Value and not Text2. Using the default property of a control is usually ok but when in trouble switch back to more explicit references.

    3) When you cast a parameter do it with the proper casting type: CLng(Me.Text1.Value) (provided that emp_no is defined as being a 4 bytes numeric value - Long in Access, Integer in SQL) and not Val(Text1).

    I hope this will help you to solve your problem.

    Have a nice day!

Posting Permissions

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