Exemple #1
0
        /// <summary>
        /// 从Web.config从读取数据库的连接以及数据库类型
        /// </summary>
        private static H31DBSQL GetSQL(string connectionStringName)
        {
            H31DBSQL h31dbsql = new H31DBSQL();

            // 从Web.config中读取数据库类型
            //string providerName = System.Configuration.ConfigurationManager.ConnectionStrings[connectionStringName].ProviderName;
            string providerName = "Access";

            switch (providerName)
            {
            case "Oracle":
                h31dbsql.DatabaseType = H31DBSQL.DatabaseTypes.Oracle;
                break;

            case "MySql":
                h31dbsql.DatabaseType = H31DBSQL.DatabaseTypes.MySql;
                break;

            case "Access":
                h31dbsql.DatabaseType = H31DBSQL.DatabaseTypes.Access;
                break;

            case "SqlClient":
            default:
                h31dbsql.DatabaseType = H31DBSQL.DatabaseTypes.Sql;
                break;
            }

            //string connstr=System.Configuration.ConfigurationManager.ConnectionStrings[connectionStringName].ConnectionString;
            string connstr = "H31DHT.mdb;Jet OLEDB:Database Password="******"Provider = Microsoft.Ace.OleDb.12.0; " + "data source=H31DHT.accdb;Persist Security Info=False;";

                /*h31dbsql.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=true;Data Source="
                 * //+ HttpContext.Current.Request.PhysicalApplicationPath
                 + connstr;*/
                break;

            default:
                h31dbsql.ConnectionString = connstr;
                break;
            }

            return(h31dbsql);
        }
Exemple #2
0
        /// <summary>
        /// 从Web.config从读取数据库的连接以及数据库类型
        /// </summary>
        private static H31DBSQL GetSQL(string connectionStringName)
        {
            H31DBSQL h31dbsql = new H31DBSQL();

            // 从Web.config中读取数据库类型
            //string providerName = System.Configuration.ConfigurationManager.ConnectionStrings[connectionStringName].ProviderName;
            string providerName = "Access";
            switch (providerName)
            {
                case "Oracle":
                    h31dbsql.DatabaseType = H31DBSQL.DatabaseTypes.Oracle;
                    break;
                case "MySql":
                    h31dbsql.DatabaseType = H31DBSQL.DatabaseTypes.MySql;
                    break;
                case "Access":
                    h31dbsql.DatabaseType = H31DBSQL.DatabaseTypes.Access;
                    break;
                case "SqlClient":
                default:
                    h31dbsql.DatabaseType = H31DBSQL.DatabaseTypes.Sql;
                    break;
            }

            //string connstr=System.Configuration.ConfigurationManager.ConnectionStrings[connectionStringName].ConnectionString;
            string connstr = "H31DHT.mdb;Jet OLEDB:Database Password="******"Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=true;Data Source="
                        //+ HttpContext.Current.Request.PhysicalApplicationPath
                        + connstr;
                    break;
                default:
                    h31dbsql.ConnectionString = connstr;
                    break;
            }

            return h31dbsql;
        }