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

刚刚学习winform,调试时总提示密码错误,我连接的是 access数据库,密码是111,请指教!
数据库连接字符串如下:总是在"conn.Open();"出错,提示密码不正确!可是就是111呀?我也打开数据库,手工输入密码“111”能够正常打开!

            string DiZhi = System.Environment.CurrentDirectory;
            string str_conn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + DiZhi + "\\system.mdb;Persist Security Info=True;Jet OLEDB:Database Password=111";


------解决方案--------------------
 public class sqlhelper
    {
        

        public sqlhelper()
        {
            //
            //TODO: 在此处添加构造函数逻辑
            //
        }

        public static string connstr = ConfigurationManager.AppSettings["accessConnStr"].ToString() + HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["accessdbPath"].ToString()) + ";";

        public static string cupage()
        {
            string strPath = "http://" + HttpContext.Current.Request.ServerVariables["HTTP_HOST"] + HttpContext.Current.Request.ServerVariables["PATH_INFO"] + "?" + HttpContext.Current.Request.ServerVariables["QUERY_STRING"];
            if (strPath.EndsWith("?"))
            {
                strPath = strPath.Substring(0, strPath.Length - 1);
            }
            return strPath;
        }


        public static int ExecuteNonQuery(CommandType cmdType, string cmdText, params OleDbParameter[] commandParameters)
        {
            OleDbCommand cmd = new OleDbCommand();