【转】ORA-01036 非法的变量名/编号,(解决)
下边的代码就会造成 ORA-01036 非法的变量名/编号
C#代码
1 cmd.CommandText = "SELECT * FROM kk.kkyh WHERE id = @comboBox1 and password = @textBox1 "; 2 3 cmd.Parameters.Add("@comboBox1", OracleType.VarChar).Value = comboBox1.Text; 4 cmd.Parameters.Add("@textBox1", OracleType.VarChar).Value = textBox1.Text;
把SQL中的@改成:,把.Add中的@去掉,就正常了
1 cmd.CommandText = "SELECT * FROM kk.kkyh WHERE id = :comboBox1 and password = :textBox1 "; 2 3 cmd.Parameters.Add("comboBox1", OracleType.VarChar).Value = comboBox1.Text; 4 cmd.Parameters.Add("textBox1", OracleType.VarChar).Value = textBox1.Text;