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.
Loading

VulpesPosted Apr 15, 2012, 1:28 PM
VulpesPosted Apr 17, 2012, 10:57 AM
Incidentally, which Oracle Data Provider are you using here?
If we can find some documentation for it, then it might give us a clue what's wrong.
Ken HPosted Apr 17, 2012, 10:50 AM
SQL> select * from user_info
2 /
ID ACCOUNT PASSWORD
-------- -------- ---------------
sp sp_user spadmin
such as,i input A'or'A'='A in password text,Can also login. Will result in security vulnerabilities.
VulpesPosted Apr 17, 2012, 5:20 AM
However, if it's still not working I don't know what else to suggest apart from not using parameters at all.
Ken HPosted Apr 16, 2012, 10:02 PM
hi Vulpes,
i not think the password as column name is reserved words in oracle,because i can use password in entity table oracle.
such as:
SQL> select * from user_info;
id password
ab ab1234
ac ac1234
2 rows selected.
thanks.
VulpesPosted Apr 16, 2012, 2:52 PM
http://docs.oracle.com/cd/B19306_01/em.102/b40103/app_oracle_reserved_words.htm
So I'd try escaping Password by enclosing it in double quotes:
cmd.CommandText = "select count(*) from User_Info where ID=:u and \"Password"\=:p";
Ken HPosted Apr 16, 2012, 12:16 PM
VulpesPosted Apr 16, 2012, 10:57 AM
Ken HPosted Apr 16, 2012, 10:31 AM
replacing with:u and with :p
It is equally wrong.
try
{
OracleCommand cmd = new OracleCommand();
conn.Open();
using (cmd = conn.CreateCommand())
{
cmd.CommandText = "select count(*) from User_Info where ID=:u and 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();
}