未处理 System.Data.OleDb.OleDbException
未处理 System.Data.OleDb.OleDbExceptionMessage="找不到文件 'D:\\My Documents\\Visual Studio 2005\\Projects\\student\\student\\bin\\Debug\\student.mdb'。"
private void button1_Click(object sender, EventArgs e)
{ //连接字符串
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;User Id=Admin;Jet OLEDB:Database Password=;Data Source=student.mdb";
//SQL语句
string strSql = @"select * from users where username='" + this.textBox1.Text + "' and pwd='" + this.textBox3.Text + "'";
//创建连接对象,用来建立与数据库的连接通信
OleDbConnection connection = new OleDbConnection(connectionString);
//打开连接对象
connection.Open();
//创建数据适配器对象
OleDbDataAdapter command = new OleDbDataAdapter(strSql, connection);
//数据集对象,存放查询结果
DataSet ds = new DataSet();
//用适配器来完成数据集填充
command.Fill(ds, "users");
//关闭连接对象