954,514 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Error: INSERT INTO Customer(Cust_ID, Name, Address, Username, Password) VALUE(?,?,?)

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.

tomexlfc
Light Poster
29 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
 

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

Phasma
Junior Poster in Training
81 posts since Nov 2008
Reputation Points: 21
Solved Threads: 21
 

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..

artemix22
Light Poster
45 posts since Jan 2012
Reputation Points: 14
Solved Threads: 5
 

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! :)

tomexlfc
Light Poster
29 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
 

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

tomexlfc
Light Poster
29 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
 
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 :)

artemix22
Light Poster
45 posts since Jan 2012
Reputation Points: 14
Solved Threads: 5
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You