Beispiel #1
0
        private MySqlSchemaCollection GetTable(string sql)
        {
            MySqlSchemaCollection mySqlSchemaCollection = new MySqlSchemaCollection();
            MySqlDataReader       mySqlDataReader       = new MySqlCommand(sql, this.connection).ExecuteReader();

            for (int i = 0; i < mySqlDataReader.FieldCount; i++)
            {
                mySqlSchemaCollection.AddColumn(mySqlDataReader.GetName(i), mySqlDataReader.GetFieldType(i));
            }
            using (mySqlDataReader)
            {
                while (mySqlDataReader.Read())
                {
                    MySqlSchemaRow mySqlSchemaRow = mySqlSchemaCollection.AddRow();
                    for (int j = 0; j < mySqlDataReader.FieldCount; j++)
                    {
                        mySqlSchemaRow[j] = mySqlDataReader.GetValue(j);
                    }
                }
            }
            return(mySqlSchemaCollection);
        }
Beispiel #2
0
        protected MySqlSchemaCollection QueryCollection(string name, string sql)
        {
            MySqlSchemaCollection schemas = new MySqlSchemaCollection(name);
            MySqlDataReader       reader  = new MySqlCommand(sql, this.connection).ExecuteReader();

            for (int i = 0; i < reader.FieldCount; i++)
            {
                schemas.AddColumn(reader.GetName(i), reader.GetFieldType(i));
            }
            using (reader)
            {
                while (reader.Read())
                {
                    MySqlSchemaRow row = schemas.AddRow();
                    for (int j = 0; j < reader.FieldCount; j++)
                    {
                        row[j] = reader.GetValue(j);
                    }
                }
            }
            return(schemas);
        }