# VB.NET simple SQL INSERT statement ??



## Hickyfunkymonkey (Mar 4, 2009)

Hey,

Im having a little problem getting an SQL query to work. I am using a vb.net application to insert a load of records into a MySQL database tables, however whenever I go to insert the record I get the following error

*You have an error in your SQL syntax; check the manual that corresponds to your MySQL server.....etc.*

Below is the code that I am using, and for debugging purposes I have hard coded the inputs.


```
[SIZE=3] Protected Sub cmdSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdSubmit.Click

        myConnection = New MySqlConnection("server=localhost; user id=xxxx.xxxx; password=Pa55word; database=eportfolio; pooling=false;")
        myConnection.Open()
        myCommand = New MySqlCommand("INSERT INTO user_prof VALUES 
[*], [Bob], [Jones], [09/11/1976], [Graduate], [[email protected]], [Bristol], [England], [Network Assistant], [Well...........Blah blah ipsum]", myConnection)

        ra = myCommand.ExecuteNonQuery()
        MsgBox("New Row Inserted" & ra)
        myConnection.Close()[/SIZE]
```
Any idea where I am going wrong here??

Thanks


----------



## JimmySeal (Sep 25, 2007)

I think the SQL syntax you want is a bit more like this:

INSERT INTO user_prof VALUES('Bob', 'Jones', '09/11/1976', 
'Graduate', '[email protected]', 'Bristol', 'England', 'Network Assistant', 'Well...........Blah blah ipsum')

Note the parentheses, single quotes and lack of brackets. Generally however, it is considered good practice to explicitly specify the column names, like:

INSERT INTO user_prof([firstName], [lastName], [dob]) VALUES('Bob', 'Jones', '09/11/1976')


----------

