这是运行后的问题
这是代码using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace LoginForm
{
public partial class Form1 : Form
{
public static string name;
public static string psw;
public static string right;
public Form1()
{
InitializeComponent();
}
private void login_btn_Click(object sender, EventArgs e)
{
if (this.textname.Text.Trim() == "" || textpsw.Text == "")
{
MessageBox.Show("请输入您的用户名和密码!", "提示!");
return;
}
string Username = textname.Text;
string Userpsw = textpsw.Text;
if (Username == "" || Userpsw == "")
{
MessageBox.Show("请输入用户名和密码!", "提示!");
}
else
{
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\\Documents\\Database2.accdb");
if (radioButton1.Checked)
{
string str = "select * from login where Usertight='" + this.textname.Text.Trim() + "'";
try
{
conn.Open();
OleDbCommand cmd = new OleDbCommand(str, conn);
OleDbDataReader read = cmd.ExecuteReader();
if (read.Read())
{
if (textpsw.Text.Trim().Equals(read["Userpsw"].ToString().Trim()))
{
MessageBox.Show("登录成功!", "欢迎登录本系统!");
this.Hide();
AdminLogin fm = new AdminLogin();
fm.Show();
}
else
{
MessageBox.Show("密码输入错误,请重新输入!");
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
if (radioButton2.Checked)
{
string str = "select * from stu where Userright='" + this.textname.Text.Trim() + "'";
try
{
conn.Open();
OleDbCommand cmd = new OleDbCommand(str, conn);
OleDbDataReader read = cmd.ExecuteReader();
if (read.Read())
{
if (textpsw.Text.Trim().Equals(read["Userpsw"].ToString().Trim()))
{
MessageBox.Show("登录成功!", "欢迎登录本系统!");
this.Hide();
StuLogin fm = new StuLogin();
fm.Show();
}
else
{
MessageBox.Show("密码输入错误,请重新输入!");
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
if (radioButton1.Checked == false && radioButton2.Checked == false)
{
MessageBox.Show("请选择权限!");
}
}
}
private void cancel_btn_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}