我要做一个用户登陆界面,用户名和密码都放在表中(oracel数据库),在界面上输入登陆名和密码后,用表中的信息验证登陆,如何实现?PS:我用的是Visual studio 2010
------解决方案--------------------------------------------------------
找到了一个,超好用!只要把语句改成oracel的就行!
SqlConnection myconn;
SqlCommand mycomd;
string connString = "server =15\\SQLEXPRESS;database =选课管理系统;integrated security = true;Pooling=False";//用windows身份登录
private void button1_Click(object sender, EventArgs e)
{
myconn = new SqlConnection(connString);
if (myconn.State == System.Data.ConnectionState.Closed)
{
try
{
myconn.Open();
}
catch (Exception a)
{
MessageBox.Show("数据库连接失败" + a.Message);
return;
}
}
mycomd = myconn.CreateCommand();
mycomd.CommandText = "select * from PassWord where stud_id='" + textBox1.Text.Trim() + "' and password='" + textBox2.Text.Trim() + "'";
if (mycomd.ExecuteReader().HasRows)
{
MessageBox.Show("登录成功!");
}
else
{
MessageBox.Show("用户名或密码不正确!!!");