SQLDataAdapter.Update

mcerk

Well-known member
Joined
Nov 1, 2004
Messages
78
Hi. I have a problem. Im 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:
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.
 
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 Id love to hear it).
 
Back
Top