示例#1
0
        public bool TestConnection(ConnectionString connectionString)
        {
            bool connectionOk;
            OleDbConnection con = new OleDbConnection(connectionString.GetConnectionString());
            OleDbCommand command = con.CreateCommand();

            command.CommandText = string.Format("USE {0}", connectionString.DatabaseName);

            try
            {
                con.Open();
                command.ExecuteScalar();

                connectionOk = true;
            }
            catch (Exception ex)
            {
                connectionOk = false;
            }
            finally
            {
                con.Close();
            }

            return connectionOk;
        }
示例#2
0
        public DataTable GetPreviewData(ConnectionString connectionString, Table table)
        {
            DataTable returnData = new DataTable();

            OleDbConnection con = new OleDbConnection(connectionString.GetConnectionString());
            OleDbCommand command = con.CreateCommand();

            command.CommandText = string.Format("SELECT TOP 1000 * FROM {0}", table.FullTableName);

            try
            {
                con.Open();
                IDataReader reader = command.ExecuteReader();

                returnData.Load(reader);
            }
            finally
            {
                con.Close();
            }

            return returnData;
        }
 public int ProcessSql(ConnectionString connectionString, string sql)
 {
     return _databaseProvider.ProcessSql(connectionString.GetConnectionString(), sql);
 }
 public List<Table> GetTablesFromDatabase(ConnectionString connectionString)
 {
     return _databaseProvider.GetSchemaInformation(connectionString.GetConnectionString());
 }
 public double GetRecrodCountForTable(ConnectionString connectionString, Table table)
 {
     return _databaseProvider.GetRecordCount(connectionString.GetConnectionString(), table);
 }
 public HashSet<string> GetDataForColumn(ConnectionString connectionString, Table table, Column column)
 {
     return _databaseProvider.GetDataForColumn(connectionString.GetConnectionString(), table, column);
 }