odbc syntax to update

2019-08-24 01:53发布

问题:

string MyConString = "DRIVER={MySQL ODBC 3.51 Driver};" + "SERVER=localhost;" + "DATABASE=new_db;" + "UID=root;" + "PASSWORD=password;" + "OPTION=3";

OdbcConnection MyConnection = new OdbcConnection(MyConString);

OdbcCommand cmd = new OdbcCommand("UPDATE awm_create SET referral_email=?' WHERE email=? " , MyConnection);

//cmd.Parameters.Add("@tb_refemail", OdbcType.VarChar, 255).Value = tb_refemail.Text.Trim();
//cmd.Parameters.Add("@tb_email", OdbcType.VarChar, 255).Value = tb_email.Text.Trim();

MyConnection.Open();

cmd.ExecuteNonQuery();

How to provide the referral_email and email using forms?

Do the comment code works in any way??

Please correct the above code

回答1:

Remove the single quote in your command text:

OdbcCommand cmd = new OdbcCommand("UPDATE awm_create 
   SET referral_email=? WHERE email=?" , MyConnection);


标签: mysql sql odbc