public ColumnDefinition[] GetSchema(string query)
        {
            List <ColumnDefinition> items = new List <ColumnDefinition>();
            OleDbCommand            cmd   = _connection.CreateCommand();

            cmd.CommandText = query;
            cmd.CommandType = CommandType.Text;
            IDataReader reader = cmd.ExecuteReader(CommandBehavior.SchemaOnly);
            DataTable   dt     = reader.GetSchemaTable();

            Provider.Access.AccessDbTypeTranslator translator = new AccessDbTypeTranslator();
            // ColumnName, ColumnSize, NumericPrecision, DataType, AllowDbNull, ProviderType,
            // IsIdentity, IsAutoIncrement, ProviderSpecificDataType, DataTypeName
            foreach (DataRow row in dt.Rows)
            {
                ColumnDefinition col = new ColumnDefinition();
                col.ColumnName = row["ColumnName"]  as string;
                col.Length     = (int)row["ColumnSize"];
                string dataType = (row["DataType"]   as Type).FullName;
                col.DataType   = translator.GetDbTypeFromSystemTypeString(dataType);
                col.IsLong     = (bool)row["IsLong"];
                col.IsNullable = (bool)row["AllowDBNull"];
                items.Add(col);
            }
            return(items.ToArray());
        }
Exemple #2
0
 public ColumnDefinition[] GetSchema(string query)
 {
     List<ColumnDefinition> items = new List<ColumnDefinition>();
     OleDbCommand cmd = _connection.CreateCommand();
     cmd.CommandText = query;
     cmd.CommandType = CommandType.Text;
     IDataReader reader = cmd.ExecuteReader(CommandBehavior.SchemaOnly);
     DataTable dt = reader.GetSchemaTable();
     Provider.Access.AccessDbTypeTranslator translator = new AccessDbTypeTranslator();
     // ColumnName, ColumnSize, NumericPrecision, DataType, AllowDbNull, ProviderType,
     // IsIdentity, IsAutoIncrement, ProviderSpecificDataType, DataTypeName
     foreach (DataRow row in dt.Rows)
     {
         ColumnDefinition col = new ColumnDefinition();
         col.ColumnName  = row["ColumnName"]  as string;
         col.Length      = (int)row["ColumnSize"];
         string dataType = (row["DataType"]   as Type).FullName;
         col.DataType = translator.GetDbTypeFromSystemTypeString(dataType);
         col.IsLong      = (bool)row["IsLong"];
         col.IsNullable = (bool)row["AllowDBNull"];
         items.Add(col);
     }
     return items.ToArray();
 }