The column class is roughly based on a DBF style struct. Names are limited to ten characters, there are a couple of datatypes; but they're all written as strings, that kind of thing. Note that NetBase currently only supports writing strings; although it can read different datatypes See the table class for more notes about the on-disk format.
Beispiel #1
0
 internal ITable Add(Sql.CreateTableQuery q)
 {
     FileTable ft = new FileTable();
     foreach (Sql.CreateTableQuery.CreateField field in q.Fields)
     {
         Column item = new Column();
         item.Name = field.Name;
         item.DataType = 'C';
         ft.Columns.Add(item);
     }
     string filename = Path.Combine(_database.Directory, q.TableName + ".DBF");
     ft.CommitToDisk(filename);
     return (ITable)ft;
 }
Beispiel #2
0
        private void Open(string filename)
        {
            this._fs = new FileStream(filename, FileMode.Open);
            this._br = new BinaryReader(this._fs);

            this.Header = new TableHeader();
            this.Header.BinRead(this._br);

            this.Columns = new List<Column>();
            for (Int16 i = 0; i < this.Header.ColumnCount; i++)
            {
                Column c = new Column();
                c.BinRead(_br);
                this.Columns.Add(c);
            }

            // Read mysterious extra byte; found in original test
            // table from a Lotus Approach database.
            _br.ReadByte();
            // Sanity check row size
            if (this.CalculateTotalRowSize() != this.Header.RowLength)
            {
                throw new BadDataException("Total size of columns does not match that defined in the header");
            }
        }