示例#1
0
        public ODBCTable(string name, string file, bool userOpen) : base(name, userOpen)
        {
            this.Name  = name;
            this._File = file;

            //We'll create the connect when the user tries to define a table.
            //In the future... we should probably do this on VM bootup. Or maybe a program to do it?
            ODBCTable.TestConnection();

            if (!userOpen)
            {
                this.Open();
            }
        }
示例#2
0
        public static DataSet CreateStruct(string name, Boolean qualified = false)
        {
            ODBCTable.TestConnection();

            DataSet Structure = new DataSet(name);

            Structure._Type      = Types.Structure;
            Structure._Qualified = qualified;
            List <DataSet> subfields = new List <DataSet>();
            DataSet        subfield;

            using (OdbcCommand com = new OdbcCommand(
                       "select * from qsys2.syscolumns where table_name = ? and table_schema = " +
                       "(select table_schema from qsys2.systables where table_name = ? limit 1)"
                       , ODBCTable.Connection))
            {
                com.Parameters.AddWithValue("@var1", name.ToUpper());
                com.Parameters.AddWithValue("@var2", name.ToUpper());

                using (OdbcDataReader reader = com.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        // Word is from the database. Do something with it.
                        subfield            = new DataSet(reader.GetString(0));
                        subfield._Type      = Reader.StringToType(reader.GetString(4));
                        subfield._Length    = reader.GetInt32(5);
                        subfield._Precision = (reader.IsDBNull(6) ? 0 : reader.GetInt32(6));
                        subfields.Add(subfield);
                    }
                }
            }

            Structure._Subfields = subfields;

            return(Structure);
        }