c# 使用 access来在 windows form 登入

来源:百度知道 编辑:UC知道 时间:2024/05/24 00:33:30
我在c# 中已建立 database 名: testing, 内有table: teee, 栏位 : id, password. lable1 是入id, lable2是入password
请问如何可以以windows form 用access 来登入...
看了很多文都看不明....急用, 跪求高手求命
OleDbConnection Myconnection = null;
OleDbDataReader dbReader = null;

Myconnection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0; User Id=; Password=; Data Source=C:\testing.mdb");
Myconnection.Open();

OleDbCommand cmd = Myconnection.CreateCommand();
cmd.CommandText = "select * from info where NO='" + NO1.ToString() + "' and Pass='" + Pass1.ToString()+ "'";
dbReader = cmd.ExecuteReader(); <----在这里就死了, 行不下去

之后的就不会了
可以教教吗??

oledbclient
//----------
cmd.CommandText = "select * from [info] where [NO]='" + NO1.ToString() + "' and [Pass]='" + Pass1.ToString()+ "'";
另外,如果NO是数字型的,可以不要单引号

连接好SQL 跳用 connection 方法连接 建立查询语句 执行 并返回 根据返回 值确定 登入情况