Exemplo n.º 1
0
        /// <summary>
        /// Enumerate columns info
        /// </summary>
        /// <param name="tableName">Table name</param>
        /// <returns>Columns info list</returns>
        public VDBColumnInfo[] EnumColumns(string tableName)
        {
            int position;
            int columnsCount;

            VDBColumnInfo[] columns;

            if (!FindTable(tableName))
            {
                return(null);
            }

            position = this.position;

            try
            {
                FindColumnSection();
                GetInteger();
                columnsCount = GetInteger();
                columns      = new VDBColumnInfo[columnsCount];

                for (int i = 0; i < columnsCount; i++)
                {
                    columns[i].Name     = GetString();
                    columns[i].Caption  = GetString();
                    columns[i].DataType = VistaDBAPI.NetDataType(GetChar().ToString());
                    columns[i].Width    = GetInteger();
                    columns[i].Decimals = GetInteger();

                    columns[i].DefValue          = GetString();
                    columns[i].Identity          = GetBool();
                    columns[i].IncStep           = GetDouble();
                    columns[i].UseDefValInUpdate = GetBool();

                    columns[i].AllowNull   = GetBool();
                    columns[i].Description = GetString();
                    columns[i].ReadOnly    = GetBool();
                    columns[i].Compressed  = GetBool();
                    columns[i].Encrypted   = GetBool();
                    columns[i].Hidden      = GetBool();
                    columns[i].PrimaryKey  = GetBool();
                    columns[i].Indexed     = GetBool();
                    columns[i].Unicode     = GetBool();

                    columns[i].FTS = GetBool();
                }
            }
            finally
            {
                this.position = position;
            }

            return(columns);
        }
Exemplo n.º 2
0
        private int InternalInitFieldDefs()
        {
            if (queryID <= 0)
            {
                return(0);
            }

            lock (syncRoot)
            {
                recordCount = VistaDBAPI.ivsql_RecCount(queryID);
                columnCount = VistaDBAPI.ivsql_ColumnCount(queryID);
                columns     = new VistaDBColumn[columnCount];
                char colType;
                int  len;

                int           columnCaptionWidth = 128;
                StringBuilder columnCaption      = new StringBuilder(columnCaptionWidth);

                int           columnNameWidth = 128;
                StringBuilder columnName      = new StringBuilder(columnNameWidth);

                VistaDBType columntype;
                bool        allowNull, readOnly, autoIncrement, primaryKey, unique, reservedWord;
                int         dataSize, columnWidth;

                string tempS;
                for (int i = 0; i < columnCount; i++)
                {
                    len = VistaDBAPI.ivsql_ColumnName(queryID, i + 1, columnName, columnNameWidth);
                    columnName.Length = len;

                    len = VistaDBAPI.ivsql_ColumnCaption(queryID, i + 1, columnCaption, columnCaptionWidth);
                    columnCaption.Length = len;

                    colType = VistaDBAPI.ivsql_ColumnType(queryID, i + 1);
                    tempS   = colType.ToString();

                    columntype = VistaDBAPI.NetDataType(tempS);

                    dataSize      = 0;                     // default
                    columnWidth   = 0;                     // default
                    allowNull     = !VistaDBAPI.ivsql_ColumnRequired(queryID, i + 1);
                    readOnly      = VistaDBAPI.ivsql_ColumnReadOnly(queryID, i + 1);
                    autoIncrement = VistaDBAPI.ivsql_ColumnIsIdentity(queryID, i + 1);
                    primaryKey    = VistaDBAPI.ivsql_ColumnIsPrimaryKey(queryID, i + 1);
                    unique        = VistaDBAPI.ivsql_ColumnIsUnique(queryID, i + 1);
                    reservedWord  = VistaDBAPI.ivsql_IsReservedWord(columnName.ToString());

                    switch (columntype)
                    {
                    case VistaDBType.Character:
                        columnWidth = VistaDBAPI.ivsql_ColumnWidth(queryID, i + 1);
                        dataSize    = columnWidth;
                        break;

                    case VistaDBType.Varchar:
                        columnWidth = VistaDBAPI.ivsql_ColumnWidth(queryID, i + 1);
                        dataSize    = columnWidth;
                        break;

                    case VistaDBType.Date:
                        dataSize = 8;
                        break;

                    case VistaDBType.DateTime:
                        dataSize = 8;
                        break;

                    case VistaDBType.Boolean:
                        dataSize = 2;
                        break;

                    case VistaDBType.Int32:
                        dataSize = 4;
                        break;

                    case VistaDBType.Int64:
                        dataSize = 8;
                        break;

                    case VistaDBType.Currency:
                        dataSize = 8;
                        break;

                    case VistaDBType.Double:
                        dataSize = 8;
                        break;

                    case VistaDBType.Memo:
                    case VistaDBType.Blob:
                    case VistaDBType.Picture:
                        dataSize = 2147483647;
                        break;

                    case VistaDBType.Guid:
                        dataSize = 16;
                        break;
                    }

                    columns[i] = new VistaDBColumn(columnName.ToString(), columntype, dataSize, (short)columnWidth, 0, allowNull, readOnly, primaryKey, unique, autoIncrement, 0, "", columnCaption.ToString(), "", reservedWord, false, false, false, false);
                }
            }

            return(errorNumber);
        }
Exemplo n.º 3
0
        private void InternalInitFieldDefs()
        {
            if (this.queryID == 0)
            {
                return;
            }

            string[]    buffer;
            string      columnName, columnCaption;
            VistaDBType columnType;
            bool        allowNull, readOnly, autoIncrement, primaryKey, unique, reservedWord;
            int         dataSize, columnWidth;
            int         index;

            lock (this)
            {
                this.columns = new VistaDBColumn[this.columnCount];
                buffer       = srv_GetStructure();
                index        = 0;

                for (int i = 0; i < this.columnCount; i++)
                {
                    columnName    = buffer[index];
                    columnType    = VistaDBAPI.NetDataType(buffer[index + 1]);
                    columnWidth   = Int32.Parse(buffer[index + 2], NumberStyles.AllowHexSpecifier);
                    columnCaption = buffer[index + 3];
                    allowNull     = buffer[index + 4] != "Y";
                    readOnly      = buffer[index + 5] == "Y";
                    autoIncrement = buffer[index + 6] == "Y";
                    primaryKey    = buffer[index + 7] == "Y";
                    unique        = buffer[index + 8] == "Y";
                    reservedWord  = buffer[index + 9] == "Y";

                    dataSize = 0;                          // default

                    switch (columnType)
                    {
                    case VistaDBType.Character:
                        dataSize = columnWidth;
                        break;

                    case VistaDBType.Varchar:
                        dataSize = columnWidth;
                        break;

                    case VistaDBType.Date:
                        dataSize = 8;
                        break;

                    case VistaDBType.DateTime:
                        dataSize = 8;
                        break;

                    case VistaDBType.Boolean:
                        dataSize = 2;
                        break;

                    case VistaDBType.Int32:
                        dataSize = 4;
                        break;

                    case VistaDBType.Int64:
                        dataSize = 8;
                        break;

                    case VistaDBType.Currency:
                        dataSize = 8;
                        break;

                    case VistaDBType.Double:
                        dataSize = 8;
                        break;

                    case VistaDBType.Memo:
                    case VistaDBType.Blob:
                    case VistaDBType.Picture:
                        dataSize = 2147483647;
                        break;

                    case VistaDBType.Guid:
                        dataSize = 16;
                        break;
                    }

                    this.columns[i] = new VistaDBColumn(columnName, columnType, dataSize, (short)columnWidth, 0, allowNull, readOnly, primaryKey, unique, autoIncrement, 0, "", columnCaption, "", reservedWord, false, false, false, false);

                    index += 10;
                }
            }
        }