G0ggy
asked on
SQL Insert for MySQL with Parameters
Hi, can some tell me why this code:
Dim con As New OdbcConnection(ConnectionS trings("de faultCon") .Connectio nString)
Dim cmdText As String = "Insert Into dk_players(emailAddress,fi rstName,la stName,web siteURL,ms nName,icqU in,aolIden tity,yahoo Identity,d ob,locatio n," & _
"dateRegistered,status,dis playName) Values (?emailAddress,?firstName, ?lastName, ?websiteUR L,?msnName ,?icqUin,? aolIdentit y,?yahooId entity,?do b," & _
"?location,?dateRegistered ,?status,? displayNam e)"
Dim cmd As OdbcCommand = New OdbcCommand(cmdText, con)
cmd.CommandType = CommandType.Text
Dim regDate As Date = DateTime.Now
cmd.Parameters.AddWithValu e("?emailA ddress", txtEmailAddress.Text)
cmd.Parameters.AddWithValu e("?firstN ame", txtRegistrantFirstName.Tex t)
cmd.Parameters.AddWithValu e("?lastNa me", txtRegistrantLastName.Text )
cmd.Parameters.AddWithValu e("?websit eURL", txtWebsiteURL.Text)
cmd.Parameters.AddWithValu e("?msnNam e", txtMSN.Text)
cmd.Parameters.AddWithValu e("?icqUin ", txtICQ.Text)
cmd.Parameters.AddWithValu e("?aolIde ntity", txtAOLIdentity.Text)
cmd.Parameters.AddWithValu e("?yahooI dentity", txtYahooIdentity.Text)
cmd.Parameters.AddWithValu e("?dob", txtDOB.Text)
cmd.Parameters.AddWithValu e("?locati on", txtLocation.Text)
cmd.Parameters.AddWithValu e("?dateRe gistered", regDate)
cmd.Parameters.AddWithValu e("?status ", 1)
cmd.Parameters.AddWithValu e("?displa yName", txtDisplayName.Text)
con.Open()
cmd.ExecuteNonQuery()
con.Close()
Produces with error:
System.Data.Odbc.OdbcExcep tion: ERROR [42000] [MySQL][ODBC 3.51 Driver][mysqld-5.0.41-comm unity-nt]Y ou 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'firstN ame,'Doe'l astName,'www.johndoe.com'websiteURL,''msnName' at line 1
Because I am stumped!!!
Cheers.
Dim con As New OdbcConnection(ConnectionS
Dim cmdText As String = "Insert Into dk_players(emailAddress,fi
"dateRegistered,status,dis
"?location,?dateRegistered
Dim cmd As OdbcCommand = New OdbcCommand(cmdText, con)
cmd.CommandType = CommandType.Text
Dim regDate As Date = DateTime.Now
cmd.Parameters.AddWithValu
cmd.Parameters.AddWithValu
cmd.Parameters.AddWithValu
cmd.Parameters.AddWithValu
cmd.Parameters.AddWithValu
cmd.Parameters.AddWithValu
cmd.Parameters.AddWithValu
cmd.Parameters.AddWithValu
cmd.Parameters.AddWithValu
cmd.Parameters.AddWithValu
cmd.Parameters.AddWithValu
cmd.Parameters.AddWithValu
cmd.Parameters.AddWithValu
con.Open()
cmd.ExecuteNonQuery()
con.Close()
Produces with error:
System.Data.Odbc.OdbcExcep
Because I am stumped!!!
Cheers.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER