Exemplo n.º 1
0
        /// <summary>
        /// 得到源数据表的DataTable
        /// </summary>
        /// <param name="strTableName">源数据表名</param>
        /// <returns>源数据表的DataTable</returns>
        private DataTable GetSourceDataTable(string strTableName)
        {
            DataTable dtSourceData = new DataTable();

            dtSourceData.TableName = strTableName;
            string sqlSelect = string.Format("SELECT * FROM {0}", strTableName);

            //对不同数据库进行判断
            if (IsSourceString.Equals(TypeProcessing.DataBase.SqlServer.ToString()))
            {
                SqlServerHelper sqlHelper = new SqlServerHelper();
                sqlHelper.SqlServerConnectionString(SourceConnectionString);
                sqlHelper.Open();
                dtSourceData = sqlHelper.GetDataTable(sqlSelect);
                sqlHelper.Close();
            }
            else if (IsSourceString.Equals(TypeProcessing.DataBase.Oracle.ToString()))
            {
                OracleHelper sqlHelper = new OracleHelper();
                sqlHelper.OracleConnectionString(SourceConnectionString);
                sqlHelper.Open();
                dtSourceData = sqlHelper.GetDataTable(sqlSelect);
                sqlHelper.Close();
            }
            else if (IsSourceString.Equals(TypeProcessing.DataBase.MySql.ToString()))
            {
                MySqlHelper sqlHelper = new MySqlHelper();
                sqlHelper.MySqlConnectionString(SourceConnectionString);
                sqlHelper.Open();
                dtSourceData = sqlHelper.GetDataTable(sqlSelect);
                sqlHelper.Close();
            }
            else if (IsSourceString.Equals(TypeProcessing.DataBase.Access.ToString()))
            {
                AccessHelper sqlHelper = new AccessHelper();
                sqlHelper.AccessConnectionString(SourceConnectionString);
                sqlHelper.Open();
                dtSourceData = sqlHelper.GetDataTable(sqlSelect);
                sqlHelper.Close();
            }
            else if (IsSourceString.Equals(TypeProcessing.DataBase.SQLite.ToString()))
            {
                SQLiteHelper sqlHelper = new SQLiteHelper();
                sqlHelper.SQLiteConnectionString(SourceConnectionString);
                sqlHelper.Open();
                dtSourceData = sqlHelper.GetDataTable(sqlSelect);
                sqlHelper.Close();
            }
            return(dtSourceData);
        }