登录
private void button1_Click(object sender, EventArgs e)
{
string u = textBox1.Text.ToString();
string p = textBox2.Text.ToString();
OracleConnection conn = new OracleConnection(@"Data Source=insure155;User ID=WZH;Unicode=True");
conn.Open();
OracleCommand cmd = conn.CreateCommand();
cmd.CommandText = "select * from insure155 where user='" + u + " '";
OracleDataReader odr = cmd.ExecuteReader();
if (odr.Read())
{
if (odr["password"].ToString().Trim() == p)
{
MessageBox.Show("恭喜您登陆成功!", "登录成功!", MessageBoxButtons.OK, MessageBoxIcon.Information);
Form1 form1 = new Form1();
form1.Show();
}
else
MessageBox.Show("密码错误,请重新输入!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
红色那段,数据库连接是成功的。大家不要笑我啊!我新手,想知道程序为什么不对,哪里错了。有好心人回答吗?希望在改程序的时候写上注释,这样可以方便我看懂!!!非常感谢!!!!
[解决办法]
cmd.CommandText = "select * from insure155 where user='" + u + " '";\
============>
cmd.CommandText = "select * from insure155 where [user]='" + u + " '";
[解决办法]