请帮我看看错在哪里!
using System;using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
using System.Data .OleDb ;
namespace 学生信息管理系统
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void comboBox1_TextChanged(object sender, EventArgs e)
{
if (() == "管理员")
{
Usertextbox.Text = "administrator";
Passwordbox.Text = "ttxlla";
}
if (() == "教师")
{
Usertextbox.Text = "teacher";
Passwordbox.Text = "teacher";
}
if (() == "学生")
{
Usertextbox.Text = "student";
Passwordbox.Text = "student";
}
else if (() == "游客")
{
Usertextbox.Text = "您将以游客身份登录!";
Passwordbox.Text = "guest";
}
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (MessageBox.Show("Sure Out?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
e.Cancel = true;
}
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void Form1_Load(object sender, EventArgs e)
{
timer1.Enabled = true;
timer1.Interval = 1000;
}
private void timer1_Tick(object sender, EventArgs e)
{
this.label5.Text = "Time is:" + System.DateTime.Now.ToString();
}
private void button1_Click(object sender, EventArgs e)
{
if (Usertextbox.Text.Trim() == "" || Passwordbox.Text.Trim() == "")
{
MessageBox.Show("Sorry!You hane not import your username or your password!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
Usertextbox.Focus();
}
else
{
string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;";
strConnection += "Data Source=";
strConnection += Application.StartupPath;
strConnection += @"\学生信息.mdb";
OleDbConnection conn = new OleDbConnection(strConnection);
conn.Open();
OleDbDataAdapter dauser = new OleDbDataAdapter("select * from 学生信息表 where 用户名='" +Usertextbox . Text.Trim() + "'+ 密码='"+Passwordbox .Text .Trim ()+"'+ 身份='"+comboBox1 .Text .Trim ()+"'", conn);
DataSet dsuser = new DataSet();
dauser.Fill(dsuser, "学生信息表");
if (dsuser.Tables[0].Rows.Count == 0)
{
MessageBox.Show("Sorry!Wrong usernam!", "message",MessageBoxButtons .OK ,MessageBoxIcon.Error );
Usertextbox.Clear();
Passwordbox.Clear();
Usertextbox .Focus ();
}
else
{
DataRow[] dr = dsuser.Tables[0].Select("用户名='" +Usertextbox . Text + "'");
if ((dr[0]["密码"].ToString(),Passwordbox . Text) == 0)
{
MessageBox.Show("Success!", "message",MessageBoxButtons .OK ,MessageBoxIcon.Asterisk );
}
else
{
MessageBox.Show("Wrong password!", "message",MessageBoxButtons .OK ,MessageBoxIcon.Error );
Passwordbox . Clear();
Passwordbox . Focus();
}
}
}
}
}
}
这是学校布置的一个作业!我运行的话没有报错!我输入错误的usernam说账号错误!但是就算我输入了正确的账号密码也是账号错误!就好像程序只运行到MessageBox.Show("Sorry!Wrong usernam!", "message",MessageBoxButtons .OK ,MessageBoxIcon.Error );地方一样!请教大虾们!这个程序错在哪里!<我的combobox功能现在可以不考虑!>