0

I just wanna ask what's wrong with my code it says syntax error on INSERT STATEMENT but I can't find the error @.@

Try
                Using conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & System.Environment.CurrentDirectory & "\employeedb.mdb;")
                    conn.Open()
                    Dim command As New OleDbCommand("INSERT INTO employees (first_name, last_name, MI, address, age, contact, status, department, gender, position, date_hired) VALUES (@fname, @lname, @initial, @address, @age, @contact, @regularradio, @dept, @gender, @pos, @date1)", conn)
                    With command.Parameters
                        .AddWithValue("@fname", fname.Text)
                        .AddWithValue("@lname", lname.Text)
                        .AddWithValue("@initial", initial.Text)
                        .AddWithValue("@address", address.Text)
                        .AddWithValue("@age", age.Text)
                        .AddWithValue("@contact", contact.Text)
                        .AddWithValue("@regularradio", regularradio.Text)
                        .AddWithValue("@dept", dept.Text)
                        .AddWithValue("@gender", gender.Text)
                        .AddWithValue("@pos", pos.Text)
                        .AddWithValue("@date1", date1.Text)
                    End With
                    command.ExecuteNonQuery()
                    MessageBox.Show("Employee's Informations Recorded!", "INFO", MessageBoxButtons.OK, MessageBoxIcon.Information)
                    command.Dispose()
                    conn.Close()
                    fname.Text = ""
                    lname.Text = ""
                    initial.Text = ""
                    address.Text = ""
                    age.Text = ""
                    contact.Text = ""
                    regularradio.Checked = False
                    dept.Text = ""
                    gender.Text = ""
                    pos.Text = ""
                    date1.Value = Now.Date
                End Using
            Catch ex As Exception
                MessageBox.Show(ex.Message, "ERROR12", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try

        End If
3
Contributors
4
Replies
12
Views
4 Years
Discussion Span
Last Post by yvrej17
0

Problem solved! Thank you^^ but another error occur it's "OVERFLOW" >.< hmmm what's that mean?

Edited by yvrej17

0

An overflow can occur when the recipient field is not larger enough for the data to be inserted.

I.E.: if the initial field in the DB is defined to be 1 carácter long but the current intial.text contains 2 characters, an overflow will occur.

Hope this helps

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.