首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

请教这段c# 连接 操作access数据库代码异常如何解决

2012-09-07 
请问这段c# 连接 操作access数据库代码错误怎么解决?C# codepublic bool isuserlogin(string upassword)//

请问这段c# 连接 操作access数据库代码错误怎么解决?

C# code
        public bool isuserlogin(string upassword)  //检测用户是否登入        {             try            {                getConnection getCon = new getConnection();                oledCon = getCon.OledCon();                oledCon.Open();                string strAdd = String.Format("select uloginstate from T_user where upassword='{0}'", upassword.Trim());                oledcmd = new OleDbCommand(strAdd, oledCon);                oleRed = oledcmd.ExecuteReader();                return oleRed;            }            catch (Exception ex)            {                MessageBox.Show(ee.Message.ToString());                return oleRed;            }        }


之前已经成功连接好了数据库 数据库中T_user表中uloginstate是 真/假值 采用密码登入 我的意图是当用户输入密码后 检测这个用户是否已经登入 uloginstate就是作为这个判断值 所以这个 类里我写的这个函数就是用来判断用户的登入状态 我希望是使这个函数 返回真假值 怎么解决这个问题?

[解决办法]
问题应该出现在方法OledCon()中.应该连接字符串出现了错误

Provider=Microsoft.ACE.OLEDB.12.0;Extended Properties='Excel 12.0;HDR=Yes;IMEX=1';Data Source=" + 路径

热点排行