Hello everyone,

Please can someone help me to debug this error? It has been giving me a huge headache since last night. Anytime I try to add new record into my database, this error message keeps coming up: "Error: INSERT INTO Customer(Cust_ID, Name, Address, Username, Password) VALUE(?,?,?,?,?,?)". I don't know where the problem lies.

Here's my code for the "add/commit" button:

Private Sub btnCommit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCommit.Click

        If inc <> -1 Then

            Dim cb As New OleDb.OleDbCommandBuilder(da)
            Dim dsNewRow As DataRow

            MessageBox.Show(cb.GetInsertCommand.CommandText)
            da.InsertCommand = cb.GetInsertCommand
            'da.UpdateCommand = cb.GetUpdateCommand
            'da.DeleteCommand = cb.GetDeleteCommand

            dsNewRow = ds.Tables("SouthCity").NewRow()

            dsNewRow.Item(0) = txtCustID.Text
            dsNewRow.Item(1) = txtCUstName.Text
            dsNewRow.Item(2) = txtAddress.Text
            dsNewRow.Item(3) = txtTelNo.Text
            dsNewRow.Item(4) = txtUsername.Text
            dsNewRow.Item(5) = txtPassword.Text

            ds.Tables("SouthCity").Rows.Add(dsNewRow)

            da.Update(ds, "SouthCity")

        End If
    End Sub

Thank you all.

Hello everyone,

Please can someone help me to debug this error? It has been giving me a huge headache since last night. Anytime I try to add new record into my database, this error message keeps coming up: "Error: INSERT INTO Customer(Cust_ID, Name, Address, Username, Password) VALUE(?,?,?,?,?,?)". I don't know where the problem lies.

Here's my code for the "add/commit" button:

Private Sub btnCommit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCommit.Click

        If inc <> -1 Then

            Dim cb As New OleDb.OleDbCommandBuilder(da)
            Dim dsNewRow As DataRow

            MessageBox.Show(cb.GetInsertCommand.CommandText)
            da.InsertCommand = cb.GetInsertCommand
            'da.UpdateCommand = cb.GetUpdateCommand
            'da.DeleteCommand = cb.GetDeleteCommand

            dsNewRow = ds.Tables("SouthCity").NewRow()

            dsNewRow.Item(0) = txtCustID.Text
            dsNewRow.Item(1) = txtCUstName.Text
            dsNewRow.Item(2) = txtAddress.Text
            dsNewRow.Item(3) = txtTelNo.Text
            dsNewRow.Item(4) = txtUsername.Text
            dsNewRow.Item(5) = txtPassword.Text

            ds.Tables("SouthCity").Rows.Add(dsNewRow)

            da.Update(ds, "SouthCity")

        End If
    End Sub

Thank you all.

well.. as far i know..

INSERT INTO Customer (Cust_ID, Name, Address, Username, Password) VALUES ('Value1', 'Value2', 'Value3', 'Value4', 'Value5');

check value that you want to insert..

Edited 4 Years Ago by artemix22: n/a

tomexlfc,
Did you use a SELECT Command on your DataAdapter to fill your Dataset Table? After you make the Adapter.Fill(DataSet,Table) you can get the Update,Insert, and Delete Commands for your DataAdapter via the CommandBuilder.

Here is a Good Example http://msdn.microsoft.com/en-us/library/system.data.oledb.oledbcommandbuilder(v=vs.90).aspx#Y0

Hi, thanks for your reply.

I just did that and it's working fine now.

Thanks for the help, much appreciated! :)

Thanks Phasma and Artemix, my system works fine now, i can add records to my database already.
Thanks once again! ;)

Thanks Phasma and Artemix, my system works fine now, i can add records to my database already.
Thanks once again! ;)

hi there.. no problem at all :)

This question has already been answered. Start a new discussion instead.