I got a table named Customer with column ID as AUTO NUMBER, Names as Short Text, Phone as Short Text, Age as Number, Deposit as Number. I still can’t figure out why this error keep popping out.
Try
conn.Open()
cmd = conn.CreateCommand()
cmd.CommandType = CommandType.Text
cmd.CommandText = "INSERT INTO Customer(Names, Phone, Age, Deposit) VALUES(@Name, @Phone, @Age, @Deposit)"
cmd.Parameters.AddWithValue("@Name", txtName.Text)
cmd.Parameters.AddWithValue("@Phone", txtPhone.Text)
cmd.Parameters.AddWithValue("@Age", txtAge.Text)
cmd.Parameters.AddWithValue("@Deposit", txtDeposit.Text)
cmd.ExecuteNonQuery()
conn.Close()
MessageBox.Show("Customer is registered into the database", "Customer Registration", MessageBoxButtons.OK, MessageBoxIcon.Information)
txtName.Text = String.Empty
txtPhone.Text = String.Empty
txtAge.Text = String.Empty
txtDeposit.Text = String.Empty
Catch ex As Exception
MessageBox.Show(ex.Message, "Uh Oh...", MessageBoxButtons.OK, MessageBoxIcon.Error)
conn.Close()
End Try
Table design of Customer
I’ve tried with and without parameter, still return the same error, I’ve reconnected the Database for several times, also not working.
New contributor
Oofie is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.