C# 登录界面代码 编译时老说数据类型问题 求教
using System;using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace jsglxt
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;data source=dl.mdb");
private void button2_Click(object sender, EventArgs e)
{
Close();
}
private void button1_Click(object sender, EventArgs e)
{
string strName = textBox1.Text;
string strPwd = textBox2.Text;
string strRole = comboBox1.Text;
string strOleDb = null;
if (strRole == "学生")
{
strOleDb = "SELECT * From 登录 WHERE flag=2 AND Username='" + strName + "' AND password='" + strPwd + "'";
}
else if (strRole == "教师")
{
strOleDb = "SELECT * From 登录 WHERE flag=1 AND Username='" + strName + "' AND password='" + strPwd + "'";
}
else if (strRole == "管理员")
{
strOleDb = "SELECT * From 登录 WHERE flag=0 AND Username='" + strName + "' AND password='" + strPwd + "'";
}
else
{
MessageBox.Show("请选择用户类型");
return;
}
OleDbCommand cmd = new OleDbCommand(strOleDb, conn);
conn.Open();
OleDbDataReader reader = cmd.ExecuteReader();
if (reader.Read())
{
if (comboBox1.Text == "学生")
{
Form2 studentform = new Form2();
//studentform.setStateName(strName);
studentform.Show();
;
this.Visible = false;
}
if (comboBox1.Text == "教师")
{
Form2 teacherform = new Form2();
//adminform.setStateName(strName);
teacherform.Show();
;
this.Visible = false;
}
if (comboBox1.Text == "管理员")
{
Form3 adminform = new Form3();
//adminform.setStateName(strName);
adminform.Show();
this.Visible = false;
}
}
else
{
MessageBox.Show("用户名或密码错误!");
}
}
}
}
编译说数据类型不对 不知道为什么 我用的Access数据库(.mdb) OleDbCommand cmd = new OleDbCommand(strOleDb, conn);编译时这句话出现上述错误 数据类型没有错啊