SQL Insert for MySQL with Parameters

Hi, can some tell me why this code:

Dim con As New OdbcConnection(ConnectionStrings("defaultCon").ConnectionString)
        Dim cmdText As String = "Insert Into dk_players(emailAddress,firstName,lastName,websiteURL,msnName,icqUin,aolIdentity,yahooIdentity,dob,location," & _
            "dateRegistered,status,displayName) Values (?emailAddress,?firstName,?lastName,?websiteURL,?msnName,?icqUin,?aolIdentity,?yahooIdentity,?dob," & _
            "?location,?dateRegistered,?status,?displayName)"

        Dim cmd As OdbcCommand = New OdbcCommand(cmdText, con)
        cmd.CommandType = CommandType.Text
        Dim regDate As Date = DateTime.Now

        cmd.Parameters.AddWithValue("?emailAddress", txtEmailAddress.Text)
        cmd.Parameters.AddWithValue("?firstName", txtRegistrantFirstName.Text)
        cmd.Parameters.AddWithValue("?lastName", txtRegistrantLastName.Text)
        cmd.Parameters.AddWithValue("?websiteURL", txtWebsiteURL.Text)
        cmd.Parameters.AddWithValue("?msnName", txtMSN.Text)
        cmd.Parameters.AddWithValue("?icqUin", txtICQ.Text)
        cmd.Parameters.AddWithValue("?aolIdentity", txtAOLIdentity.Text)
        cmd.Parameters.AddWithValue("?yahooIdentity", txtYahooIdentity.Text)
        cmd.Parameters.AddWithValue("?dob", txtDOB.Text)
        cmd.Parameters.AddWithValue("?location", txtLocation.Text)
        cmd.Parameters.AddWithValue("?dateRegistered", regDate)
        cmd.Parameters.AddWithValue("?status", 1)
        cmd.Parameters.AddWithValue("?displayName", txtDisplayName.Text)

        con.Open()
        cmd.ExecuteNonQuery()
        con.Close()

Produces with error:

System.Data.Odbc.OdbcException: ERROR [42000] [MySQL][ODBC 3.51 Driver][mysqld-5.0.41-community-nt]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'emailAddress,'John'firstName,'Doe'lastName,'www.johndoe.com'websiteURL,''msnName' at line 1

Because I am stumped!!!

Cheers.
LVL 11
G0ggyAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
Dim con As New OdbcConnection(ConnectionStrings("defaultCon").ConnectionString)
        Dim cmdText As String = "Insert Into dk_players(emailAddress,firstName,lastName,websiteURL,msnName,icqUin,aolIdentity,yahooIdentity,dob,location," & _
            "dateRegistered,status,displayName) Values (?,?,?,?,?,?,?,?,?," & _
            "?,?,?,?)"

odbccommand does not support named parameters, hence you must to like above, and add the parameters in the correct order.
0
 
G0ggyAuthor Commented:
Thank you so much!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.