Beispiel #1
0
        private static void TestSQL(IMyMetaTestContext criteria, dbRoot root)
        {
            IDbConnection conn = root.PluginSpecificData(root.DriverString, "internalconnection") as IDbConnection;

            if (conn != null)
            {
                IDbCommand cmd = conn.CreateCommand();
                cmd.CommandText = "select * from TEST_DATATYPES";
                IDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    for (int i = 0; i < reader.FieldCount; i++)
                    {
                        try
                        {
                            string name    = reader.GetName(i);
                            string dtname  = reader.GetDataTypeName(i);
                            string dtname2 = reader.GetFieldType(i).Name;
                            criteria.AppendLog(name + "\t=\t" + dtname + "\t=\t" + dtname2);
                        }
                        catch { }
                    }
                }
            }
        }
Beispiel #2
0
        public IDbConnection OpenConnection(string database)
        {
            //dbRoot mymeta = new dbRoot();
            dbRoot        mymeta      = CurrentDbRoot();
            IDbConnection _connection = null;

            try
            {
                // special code to handle databases that cannot have multiple open connections.
                object v = mymeta.PluginSpecificData(DbDriver, "requiresinternalconnection");
                if (v != null && v.GetType() == typeof(bool))
                {
                    if ((bool)v)
                    {
                        _connection = mymeta.PluginSpecificData(DbDriver, "internalconnection") as IDbConnection;
                    }
                }

                // The standard connection code.
                if (_connection == null)
                {
                    _connection = mymeta.BuildConnection(DbDriver, ConnectionString);
                }

                if (_connection != null)
                {
                    if (_connection.State != ConnectionState.Open)
                    {
                        _connection.Open();
                    }

                    if (!string.IsNullOrEmpty(database))
                    {
                        mymeta.ChangeDatabase(_connection, database);
                    }
                }
            }
            catch (Exception ex)
            {
                this._mdi.ErrorList.AddErrors(ex);
            }
            return(_connection);
        }