here's my code and that the error whenever i would add something to database.
i hope someone can help thanks :)

 Dim dbDataReader As OleDb.OleDbDataReader = Nothing
        Dim sqlAdd As String = "INSERT INTO Guest VALUES ('" & txtName.Text & "', '" & txtGuestId.Text & "')"
        If performNonQuery(connectionString, sqlAdd) Then
            MessageBox.Show("Congratulation you are now a member.")
        Else
            MessageBox.Show("error in saving.")
        End If


        If IsNumeric(txtName) Then
            MessageBox.Show("That is INVALID Sir/Madam")
            txtName.Text = "LASTNAME, FIRSTNAME MI."

        End If

Recommended Answers

All 2 Replies

Try explicitly naming the fields in the insert as in

INSERT INTO myTable (lname,fname) VALUES('Bunker','Archie')

As Jim says, you need to Explicitly tell SQL Server which columns you are inserting your data into. For example, say I had a table with two columns A and B both these SQL statements are valid:

INSERT INTO MYTable (A,B) VALUES (Value1, Value2)

INSERT INTO MYTable (B,A) VALUES(Value1, Value2)

So when the DB parses the statement, it does not know which columns you wish to use unless you tell it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.