日期:2014-05-17  浏览次数:20751 次

C# 登陆模块 数据库连接
                
             OleDbConnection strConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + "新生报到管理系统.mdb" + ";Persist Security Info=False");
 
            //建立数据库引擎连接,注意数据表(后缀为.db)应放在DEBUG文件下
            // OleDbDataAdapter myda = new OleDbDataAdapter("select * from 登陆 ",strConnection);

             string sql="select * from login where userName='"+userName.Text + "'and userPassword='"+userPassword.Text+"'and userID='"+userID.Text;
             strConnection.Open();// "select * from user where username=
             OleDbCommand commd = new OleDbCommand(sql, strConnection);
             OleDbDataReader odr = commd.ExecuteReader();
             if (odr.Read())
             {
                 MessageBox.Show("登入成功!");
                          
             }
             else
             {
                 MessageBox.Show("登入失败!");
             }

运行有问题但是百度谷歌都没有找出
C#??登陆模块??数据库连接

------解决方案--------------------
1.可以试用用Try Catch找到更清晰的信息
2.看上去是Sql语句,而不是数据库问题,是不是UserId是int,但你的UserId是‘超级管理员’  
------解决方案--------------------
...... +"'and userID='"+userID.Text + "'";

晕死!
------解决方案--------------------
OleDbConnection strConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + "新生报到管理系统.mdb" + ";Persist Security Info=False");
  
            //建立数据库引擎连接,注意数据表(后缀为.db)应放在DEBUG文件下
            // OleDbDataAdapter myda = new OleDbDataAdapter("select * from 登陆 ",strConnection);
 
             string sql="select * from login where userName='"+userName.Text + "'and userPassword='"+userPassword.Text+"'and userID='"+userID.Text+"'";
             strConnection.Open();// "select * from user&n