| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2228 人关注过本帖
标题:如何连接ACCESS数据库验证登录?
取消只看楼主 加入收藏
zjdjh
Rank: 1
等 级:新手上路
帖 子:63
专家分:0
注 册:2005-12-22
结帖率:50%
收藏
已结贴  问题点数:10 回复次数:0 
如何连接ACCESS数据库验证登录?
试了以下代码,提示 OleDbDataReader reader = cmd.ExecuteReader();
这一句错误:
“标准表达式中数据类型不匹配。 ”
请大侠帮忙!!!
 
                    string strPath = Application.StartupPath + "\\gk.mdb";
                    string strconn = "provider=microsoft.jet.oledb.4.0;data source='" + strPath + "'";
                    OleDbConnection oleconn = new OleDbConnection(strconn);
                    
                    string strcmd = "select * from tb_user where username='" + txtuser.Text.Trim() + "'and userpwd='" + txtpwd.Text.Trim() + "' ";
                    OleDbCommand cmd = new OleDbCommand(strcmd, oleconn);
                    oleconn.Open();
                    OleDbDataReader reader =cmd.ExecuteReader();
                    try
                    {
                        reader.Read();
                        if (reader.HasRows)
                        {
                            string pp = txtuser.Text;

                            // Frm_Main newfrm = new Frm_Main(pp);
                            frm_main main = new frm_main();
                            main.Show();
                            this.Hide();
                        }
                        else
                        {
                            MessageBox.Show("用户名或密码错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            txtuser.Text = "";
                            txtpwd.Text = "";
                            txtuser.Focus();
                        }
                    }

                    finally
                    {
                        if (reader != null)
                            oleconn.Close();
                    }


[ 本帖最后由 zjdjh 于 2012-3-12 21:46 编辑 ]
搜索更多相关主题的帖子: 数据库 数据 source 表达式 where 
2012-03-12 21:34
快速回复:如何连接ACCESS数据库验证登录?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.027296 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved