SqlConnection cn = new SqlConnection();
cn.ConnectionString = "Data Source=192.168.16.71;Initial Catalog=myWork;User ID=sa;Password=sa";
try
{
cn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = cn;
string sql2 = "select * from dbo.工作微博 where 姓名='" + this.textBox1.Text + "' and 密码='" + this.textBox2.Text + "'";
cmd.CommandText = sql2;
cmd.CommandType = CommandType.Text;
SqlDataReader reader = cmd.ExecuteReader();
if (reader.Read()) //如果找到用户信息,说明登录成功
{
switch ("select 权限 from dbo.工作微博 where 姓名='" + this.textBox1.Text + "'")
{
case"0":
Form2 newForm = new Form2();
newForm.Show(); //弹出主窗体
break;
case "1":
Form3 f3 = new Form3();
f3.Show(); //弹出主窗体
break;
case "2":
Form1 f1 = new Form1();
f1.Show(); //弹出主窗体
break;
}