Ejemplo n.º 1
0
        public static string GetDbConnection()
        {
            string connection_string = "";

            try
            {
                //从Config配置文件中获取数据库连接字符串并返回OleDb连接
                //System.Data.OleDb.OleDbConnection oleconn = new System.Data.OleDb.OleDbConnection(SunnyWMSClient.Properties.Settings.Default.CodeMaintainConnectionString);

                if (CommonDa.GetDbType() == EnumDbTypes.PgSql)
                {
                    connection_string = ConfigIO.GetConnectionString("postgresql_conn");
                }
                else if (CommonDa.GetDbType() == EnumDbTypes.Sqlite)
                {
                    connection_string = ConfigIO.GetConnectionString("sqlite_conn");
                }
            }
            catch (Exception ex)
            {
                throw ex;
                return("");
                //return null;
            }

            return(connection_string);
        }
Ejemplo n.º 2
0
        public static string GetConnectionString(string ConnectionName)
        {
            string connectionString = @"Data Source=" + Application.StartupPath + "\\" + ConfigurationManager.ConnectionStrings[ConnectionName].ConnectionString.ToString();

            if (CommonDa.GetDbType() == EnumDbTypes.PgSql)
            {
                connectionString = ConfigurationManager.ConnectionStrings[ConnectionName].ConnectionString.ToString();
            }

            return(connectionString);
        }
Ejemplo n.º 3
0
 internal static DataSet ExecuteQuery(string strsql)
 {
     if (CommonDa.GetDbType() == EnumDbTypes.Sqlite)
     {
         return(CommonDaSqlite.ExecuteQuery(strsql));
     }
     else
     {
         return(Common.CommonDaPgsql.ExecuteQuery(strsql));
     }
 }