public static string GetDbConnection(string sConfigPara) { 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"); if (sConfigPara.Trim() != "") { connection_string = ConfigIO.GetConnectionString(sConfigPara); } ; } } catch (Exception ex) { throw ex; return(""); //return null; } return(connection_string); }
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); }
internal static DataSet ExecuteQuery(string strsql) { if (CommonDa.GetDbType() == EnumDbTypes.Sqlite) { return(CommonDaSqlite.ExecuteQuery(strsql)); } else { return(Common.CommonDaPgsql.ExecuteQuery(strsql)); } }