Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi. I have a problem. I'm using SQL data adapter to connect to the database. It works fine, but when I want to uprate it, it returns an error. Can you please help me?

 

Here is the code:

       Select Case SaveAction
           Case "Edit"
               'edit
               Dim CurrentRow As DataRow
               CurrentRow = Me.DsUsers1.HY_Users.Rows(Me.BindingContext(Me.DsUsers1.HY_Users).Position)
               With CurrentRow
                   .BeginEdit()
                   .Item("Name") = Me.txtName.Text
                   .Item("Surname") = Me.txtSurname.Text
                   .Item("Email") = Me.txtEmail.Text
                   .Item("UsernameWeb") = Me.txtUsernameWeb.Text
                   .Item("Password") = Me.txtPassword.Text
                   .Item("PinCode") = CInt(Me.txtPINCode.Text)
                   .Item("UserLevel") = CInt(Me.txtUserlevel.Text)
                   .EndEdit()
               End With
           Case "Insert"
               'insert
               Dim NewRow As DataRow
               NewRow = Me.DsUsers1.HY_Users.NewRow
               With NewRow
                   .Item("Name") = Me.txtName.Text
                   .Item("Surname") = Me.txtSurname.Text
                   .Item("Email") = Me.txtEmail.Text
                   .Item("UsernameWeb") = Me.txtUsernameWeb.Text
                   .Item("Password") = Me.txtPassword.Text
                   .Item("PinCode") = Me.txtPINCode.Text
                   .Item("UserLevel") = Me.txtUserlevel.Text
               End With
               Me.DsUsers1.HY_Users.Rows.Add(NewRow)
           Case ""
           Case Else
               PopupBox("DEVELOPER MESSAGE, SaveAction does not exist")
       End Select
       SaveAction = ""


       Me.SqlDataAdapter1.Update(Me.DsUsers1, "HY_Users")  'UNDONE: There it returns this error:

'An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll
'Additional information: System error.

Posted

There is a problem with your UpdateCommand, InsertCommand, or DeleteCommand on your data adapter.

 

Make sure the SQL/sproc you are using is fully tested. This is one of my major gripes with using data adapters, is that its difficult to debug the Update() method, so much crap goes on, and you have no visibility as to how or where it fails. (If anybody knows of a way to debug whats going on easily I'd love to hear it).

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...