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

Recommended Answers

All 4 Replies

Position is a reserved word, you should put it in braces: [Position].
I think this should solve your problem.

It's always good to put names inside [], it can save a lot of time trying to find an error.

Look at this link for more information: http://msdn.microsoft.com/en-us/library/aa238507(v=sql.80).aspx

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

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

I see :) problem solved! Thanx guys :)

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.