ORA-01036 非法的变量名/编号,(解决)

下边的代码就会造成  ORA-01036 非法的变量名/编号

cmd.CommandText = "SELECT * FROM kk.kkyh WHERE id = @comboBox1 and password = @textBox1 ";

cmd.Parameters.Add("@comboBox1", OracleType.VarChar).Value = comboBox1.Text;
cmd.Parameters.Add("@textBox1", OracleType.VarChar).Value = textBox1.Text;

 

把SQL中的@改成:,把.Add中的@去掉,就正常了

 

cmd.CommandText = "SELECT * FROM kk.kkyh WHERE id = :comboBox1 and password = :textBox1 ";

cmd.Parameters.Add("comboBox1", OracleType.VarChar).Value = comboBox1.Text;
cmd.Parameters.Add("textBox1", OracleType.VarChar).Value = textBox1.Text;

 

黑色头发  http://heisetoufa.iteye.com

你可能感兴趣的:(oracle)