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


VulpesRank #55 · 29.2K reputationPosted Apr 15, 2012, 9:28 AM EDT
Ken HRank #2,315 · 610 reputationPosted Apr 16, 2012, 6:31 AM EDT
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();
}
VulpesRank #55 · 29.2K reputationPosted Apr 16, 2012, 6:57 AM EDT
Ken HRank #2,315 · 610 reputationPosted Apr 16, 2012, 8:16 AM EDT
VulpesRank #55 · 29.2K reputationPosted Apr 16, 2012, 10:52 AM EDT
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 HRank #2,315 · 610 reputationPosted Apr 16, 2012, 6:02 PM EDT
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.
VulpesRank #55 · 29.2K reputationPosted Apr 17, 2012, 1:20 AM EDT
However, if it's still not working I don't know what else to suggest apart from not using parameters at all.
Ken HRank #2,315 · 610 reputationPosted Apr 17, 2012, 6:50 AM EDT
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.
VulpesRank #55 · 29.2K reputationPosted Apr 17, 2012, 6:57 AM EDT
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.