Ken H

Ken H

  • NA
  • 646
  • 360.7k

Oracle sql statement parameters errors in c#

Apr 15 2012 1:06 PM
hi,
try
  {
 
  OracleCommand cmd = new OracleCommand();
  conn.Open();
  using (cmd = conn.CreateCommand())
  {
 
  cmd.CommandText = "select count(*) from User_Info where Password=@p";
  cmd.Parameters.Add(new OracleParameter("@u",this.txtUser.Text));
cmd.Parameters.Add(new OracleParameter("@p",this.txtPassword.Text)); 
int i = Convert.ToInt32(cmd.ExecuteScalar());
  if (i > 0)
  {
  this.Hide();
  conn.Close();
  }
  else
  {
  conn.Close();
  MessageBox.Show("the username or password is error!");
  }
  }
  }
  catch (Exception ex)
  {
  MessageBox.Show(ex.Message);
  conn.Close();
  } 
Run-time, display the "illegal variable name / number"
thank very much.



Answers (9)