Link to home
Start Free TrialLog in
Avatar of G0ggy
G0ggyFlag for United Kingdom of Great Britain and Northern Ireland

asked on

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.
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of G0ggy

ASKER

Thank you so much!