Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            //var adapter = fact.CreateDataAdapter();
            //adapter.SelectCommand = conn.CreateCommand();
            //adapter.SelectCommand.CommandText = textBox2.Text.ToString();
            //var set = new DataSet();
            //adapter.Fill(set);

            //DataViewManager dvm = new DataViewManager(set);
            //dvm.DataViewSettings[]

            try
            {
                DataTable t = DbProviderFactories.GetFactoryClasses();
                dataGridView1.DataSource = t;
                comboBox1.Items.Clear();
                foreach (DataRow dr in t.Rows)
                {
                    comboBox1.Items.Add(dr["InvariantName"]);
                }
                comboBox1.SelectedIndex = 0;
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message);
            }
        }
        private static DbProviderFactoryClass[] GetDbProviderFactoryClasses()
        {
            List <DbProviderFactoryClass> list = DbProviderFactories.GetFactoryClasses().ToList <DbProviderFactoryClass>();

            var types = typeof(DbProviderFactory).GetSubClass().Where(t => !t.IsAbstract);

            foreach (Type type in types)
            {
                if (!list.Any(item => item.AssemblyQualifiedName == type.AssemblyQualifiedName || item.InvariantName == type.Namespace))
                {
                    DbProviderFactoryClass item = new DbProviderFactoryClass();
                    string name = type.Name.Replace("Factory", "");
                    item.Name                  = name + " Data Provider";
                    item.Description           = ".NET Framework Data Provider for " + name;
                    item.InvariantName         = type.Namespace;
                    item.AssemblyQualifiedName = type.AssemblyQualifiedName;
                    list.Add(item);
                }
            }

            DbProviderFactoryClass[] factories = list.Where(
                item =>
            {
                Type type = null;
                return(Types.TryGetType(item.AssemblyQualifiedName, out type));
            }).ToArray();

            return(factories);
        }
Ejemplo n.º 3
0
        public static DbConnection GetConnection(string connectionName)
        {
            string providerName = null;
            string connStr      = ConfigurationManager.ConnectionStrings[connectionName].ConnectionString;

            var css = ConfigurationManager.ConnectionStrings.Cast <ConnectionStringSettings>().FirstOrDefault(x => x.ConnectionString == connStr);

            if (css != null)
            {
                providerName = css.ProviderName;
            }

            if (providerName != null)
            {
                var providerExists = DbProviderFactories.GetFactoryClasses().Rows.Cast <DataRow>().Any(r => r[2].Equals(providerName));
                if (providerExists)
                {
                    var factory      = DbProviderFactories.GetFactory(providerName);
                    var dbConnection = factory.CreateConnection();

                    dbConnection.ConnectionString = connStr;
                    return(dbConnection);
                }
            }

            return(null);
        }
        public static string GetProviderInvariantName(this DbProviderFactory factory)
        {
            DebugCheck.NotNull(factory);

            const int invariantNameIndex = 2;

#if NETSTANDARD
            var dataRows = DbProviderFactoriesCore.GetFactoryClasses().Rows.OfType <DataRow>();

            var row = new ProviderRowFinder().FindRow(
                factory.GetType(),
                r => DbProviderFactoriesCore.GetFactory(r).GetType() == factory.GetType(),
                dataRows);
#else
            var dataRows = DbProviderFactories.GetFactoryClasses().Rows.OfType <DataRow>();

            var row = new ProviderRowFinder().FindRow(
                factory.GetType(),
                r => DbProviderFactories.GetFactory(r).GetType() == factory.GetType(),
                dataRows);
#endif

            if (row == null)
            {
                throw new NotSupportedException(Strings.ProviderNameNotFound(factory));
            }

            return((string)row[invariantNameIndex]);
        }
Ejemplo n.º 5
0
        public TestCasesDialog()
        {
            InitializeComponent();

            using (DataTable tbl = DbProviderFactories.GetFactoryClasses())
            {
                foreach (DataRow row in tbl.Rows)
                {
                    string prov = row[2].ToString();

                    if (prov.IndexOf("SQLite", 0, StringComparison.OrdinalIgnoreCase) != -1 ||
                        prov.IndexOf("SqlClient", 0, StringComparison.OrdinalIgnoreCase) != -1
                        )
                    {
                        _provider.Items.Add(prov);
                    }
                    if (prov == "System.Data.SQLite")
                    {
                        _provider.SelectedItem = prov;
                    }
                }
            }
            _connectionString.Items.Add("Data Source=Test.db3;Pooling=true;FailIfMissing=false");
            _connectionString.Items.Add("Data Source=(local);Initial Catalog=sqlite;Integrated Security=True;Max Pool Size=10");
            _connectionString.SelectedIndex = 0;

            _testitems = new TestCases();
            foreach (KeyValuePair <string, bool> pair in _testitems.Tests)
            {
                ToolStripMenuItem item = (ToolStripMenuItem)testMenu.DropDownItems.Add(pair.Key, null, new EventHandler(_tests_Clicked));
                item.Checked      = true;
                item.CheckOnClick = true;
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Seeks for database provider factory classes from GAC or as indicated by
        /// the configuration file, see at <see href="https://msdn.microsoft.com/en-us/library/dd0w4a2z%28v=vs.110%29.aspx">Obtaining a DbProviderFactory</see>.
        /// </summary>
        /// <returns>Database constants with values from <see cref="DbProviderFactories"/> augmented with other predefined data in <see cref="RelationalConstants"/>.</returns>
        /// <remarks>Every call may potentially update data as it is refreshed from <see cref="DbProviderFactories"/>.</remarks>
        public static IEnumerable <RelationalConstants> GetRelationalConstants()
        {
            //This method seeks for factory classes either from the GAC or as indicated in a config file.
            var factoryData = DbProviderFactories.GetFactoryClasses();

            //The provided default information will be loaded from here to the factory constants
            //which are further augmented with predefined query templates.
            foreach (DataRow row in factoryData.Rows)
            {
                var invariantName = row[InvariantNameKey].ToString();
                AddOrModifyFactoryConstant(invariantName, InvariantNameKey, invariantName);
                AddOrModifyFactoryConstant(invariantName, NameKey, row[NameKey].ToString());
                AddOrModifyFactoryConstant(invariantName, DescriptionKey, row[DescriptionKey].ToString());
                AddOrModifyFactoryConstant(invariantName, AssemblyQualifiedNameKey, row[AssemblyQualifiedNameKey].ToString());
            }

            //And last, the constant instances are created, filled and returned.
            return(FactoryConstants.Select(i => new RelationalConstants(
                                               i.Value[InvariantNameKey],
                                               i.Value[NameKey],
                                               i.Value[DescriptionKey],
                                               i.Value[AssemblyQualifiedNameKey],
                                               i.Value.GetValueOrDefault(DefaultConnectionStringKey),
                                               i.Value.GetValueOrDefault(CreateDatabaseKey),
                                               i.Value.GetValueOrDefault(ExistsDatabaseKey))));
        }
Ejemplo n.º 7
0
        private void button1_Click(object sender, EventArgs e)
        {
            DataTable         classes = DbProviderFactories.GetFactoryClasses();
            DbProviderFactory factory = DbProviderFactories.GetFactory(classes.Rows[3]);

            DbConnection connection = factory.CreateConnection();

            connection.ConnectionString = //""; sequrete data

                                          connection.Open();

            DbCommand command = connection.CreateCommand();

            command.CommandText = @"SELECT name, rent FROM property WHERE rent = (SELECT MAX(rent) FROM property);";

            DbDataReader reader = command.ExecuteReader();

            if (reader.HasRows)
            {
                if (reader.Read())
                {
                    textBox1.Text = reader[0].ToString() + ", " + reader[1].ToString();
                }
            }
            reader.Close();

            connection.Close();
        }
Ejemplo n.º 8
0
        // Constructor that accepts the connectionString and Database ProviderName i.e SQL or Oracle
        public ConnectionProvider(string connectionString, string connectionProviderName)
        {
            this.ConnectionString = connectionString;
            DataTable table = DbProviderFactories.GetFactoryClasses();

            factory = DbProviderFactories.GetFactory(connectionProviderName);
        }
Ejemplo n.º 9
0
        private void frmDBConfig_Load(object sender, EventArgs e)
        {
            xtraTabControl1.ShowTabHeader = DevExpress.Utils.DefaultBoolean.False;
            DataTable dt = DbProviderFactories.GetFactoryClasses();

            txt_ProviderName.Properties.DataSource = dt;
        }
Ejemplo n.º 10
0
        private DbProviderFactory GetDbProviderFactory(SBD.DbType dbType)
        {
            DataTable         availableFactories = DbProviderFactories.GetFactoryClasses();
            DataColumn        providerNameCol    = availableFactories.Columns["InvariantName"];
            DbProviderFactory selectedFactory    = null;

            foreach (DataRow factoryRow in availableFactories.Rows)
            {
                var providerName = (string)factoryRow[providerNameCol.Ordinal];
                switch (dbType)
                {
                case SBD.DbType.SqlServer:
                    if (providerName == "System.Data.SqlClient")
                    {
                        selectedFactory = DbProviderFactories.GetFactory(factoryRow);
                    }
                    break;

                case SBD.DbType.Oracle:
                    if (providerName == "Oracle.DataAccess.Client")
                    {
                        selectedFactory = DbProviderFactories.GetFactory(factoryRow);
                    }
                    break;
                }
                if (selectedFactory != null)
                {
                    break;
                }
            }
            return(selectedFactory);
        }
Ejemplo n.º 11
0
        static void engageTestMode(CodeGenArgs args2, string invariantName)
        {
            DbProviderFactory factory;
            DataTable         dt;
            //string invariantName;

            FactoryTester ft;

            try {
                if (!string.IsNullOrEmpty(invariantName))
                {
                    //testFactory(DbProviderFactories.GetFactory(invariantName));
                    ft = new FactoryTester(DbProviderFactories.GetFactory(invariantName));
                    ft.doTests();
                }
                else
                {
                    dt = DbProviderFactories.GetFactoryClasses();
                    for (int nrow = 0; nrow < dt.Rows.Count; nrow++)
                    {
                        invariantName = dt.Rows[nrow]["InvariantName"].ToString();
                        engageTestMode(null, invariantName);
                        //factory = DbProviderFactories.GetFactory(invariantName);
                        //testFactory(factory);
                    }
                }
            } catch (ConfigurationErrorsException cee) {
                Logger.log(MethodBase.GetCurrentMethod(), cee);
            } catch (ArgumentException ae) {
                Logger.log(MethodBase.GetCurrentMethod(), ae);
            } catch (Exception ex) {
                Logger.log(MethodBase.GetCurrentMethod(), ex);
            }
        }
Ejemplo n.º 12
0
        public void T0020_DbProviderFactories_GetFactory()
        {
            var cs           = ConfigurationManager.ConnectionStrings["MyConnectionString"];
            var providerName = cs.ProviderName;

            var table = DbProviderFactories.GetFactoryClasses();             // Name, Description, InvariantName, AssemblyQualifiedName

            Assert.IsNotNull(table);

            var Rows = table.Select(string.Format("InvariantName = '{0}'", providerName));

            Assert.AreEqual(Rows.Length, 1);

            var assemblyQualifiedName = Rows [0] ["AssemblyQualifiedName"];

            Assert.IsNotNullOrEmpty(assemblyQualifiedName as string);
            Type   t   = typeof(Deveel.Data.Client.DeveelDbClientFactory);
            string aqn = t.FullName + ", " + t.Assembly.FullName.ToString();
            //Assert.AreEqual (aqn, (string)assemblyQualifiedName);

            // see http://www.mono-project.com/docs/advanced/pinvoke/dllnotfoundexception/
            // on how to view load info with MONO_LOG_LEVEL=debug /usr/bin/mono ...
            Type providerType = Type.GetType((string)assemblyQualifiedName);

            Assert.IsNotNull(providerType);

            var factory = DbProviderFactories.GetFactory(providerName);

            Assert.IsNotNull(factory);
        }
Ejemplo n.º 13
0
        private void SetFactory()
        {
            try
            {
                Factory = DbProviderFactories.GetFactory(ProviderName);
            }
            catch (FileLoadException ex)
            {
                throw new MassiveException(
                          string.Format(
                              "Could not load the specified provider: {0}. Have you added a reference to the correct assembly?",
                              ProviderName), ex);
            }
            catch (ArgumentException e)
            {
                var foundClasses = "I did find these Factories:";
                var dt           = DbProviderFactories.GetFactoryClasses();
                for (var i = 0; i < dt.Rows.Count; i++)
                {
                    foundClasses += String.Format("|{0}|", dt.Rows[i][2]);
                }

                throw new ArgumentException(String.Format("{0}{1}{2}", e.Message, Environment.NewLine, foundClasses));
            }
        }
Ejemplo n.º 14
0
        public ConnectionDialog(ModelItem modelItem)
        {
            ProviderNames = new List <string>();
            List <string> providers = new List <string>();

#if NETFRAMEWORK
            providers.Add("Oracle.ManagedDataAccess.Client");
#endif
#if NETCOREAPP
            DbProviderFactories.RegisterFactory("System.Data.SqlClient", System.Data.SqlClient.SqlClientFactory.Instance);
            DbProviderFactories.RegisterFactory("System.Data.OleDb", System.Data.OleDb.OleDbFactory.Instance);
            DbProviderFactories.RegisterFactory("System.Data.Odbc", System.Data.Odbc.OdbcFactory.Instance);
            DbProviderFactories.RegisterFactory("Oracle.ManagedDataAccess.Client", Oracle.ManagedDataAccess.Client.OracleClientFactory.Instance);
#endif
            var installedProviders = DbProviderFactories.GetFactoryClasses();
            foreach (DataRow installedProvider in installedProviders.Rows)
            {
                ProviderNames.Add(installedProvider["InvariantName"] as string);
            }
            foreach (var provider in providers)
            {
                if (!ProviderNames.Contains(provider))
                {
                    ProviderNames.Add(provider);
                }
            }
            InitializeComponent();
            ModelItem = modelItem;
            Context   = modelItem.GetEditingContext();
        }
Ejemplo n.º 15
0
        //TODO : This does not quite work as expected need to re-vist
        private static void RegisterProvider()
        {
            // Registering the private deployed Teradata provide using the SQL CE provider workaround as a base
            // http://stackoverflow.com/questions/1117683/add-a-dbproviderfactory-without-an-app-config


            DataTable dt = DbProviderFactories.GetFactoryClasses();

            foreach (DataRow row in dt.Rows)
            {
                Console.WriteLine(row[0].ToString());
            }

            DataSet dataSet = ConfigurationManager.GetSection("system.data") as DataSet;

            if (dataSet == null)
            {
                throw new InvalidOperationException("cannot configure privately deployed Teradata native provider");
            }

            DataRow[] dataRows = dataSet.Tables[0].Select(string.Format(CultureInfo.InvariantCulture, "InvariantName='{0}'", "Teradata.Client.Provider"));
            foreach (var dataRow in dataRows)
            {
                dataSet.Tables[0].Rows.Remove(dataRow);
            }

            dataSet.Tables[0].Rows.Add(
                ".NET Data Provider for Teradata",
                ".NET Framework Data Provider for Teradata",
                "Teradata.Client.Provider",
                "Teradata.Client.Provider.TdFactory, Teradata.Client.Provider, Version=13.1.0.4, Culture=neutral, PublicKeyToken=76b417ee2e04956c");
        }
        public static string GetProviderInvariantName(this DbProviderFactory factory)
        {
            DebugCheck.NotNull(factory);

            const int invariantNameIndex = 2;

            var dataRows = DbProviderFactories.GetFactoryClasses().Rows.OfType <DataRow>();

            var row = new ProviderRowFinder().FindRow(
                factory.GetType(),
                r => DbProviderFactories.GetFactory(r).GetType() == factory.GetType(),
                dataRows);

            if (row == null)
            {
                if (factory.GetType() == typeof(SqlClientFactory))
                {
                    return("System.Data.SqlClient");
                }

                throw new NotSupportedException(Strings.ProviderNameNotFound(factory));
            }

            return((string)row[invariantNameIndex]);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Constructor
        /// </summary>
        public SyncQueue()
        {
            messageQueue = new Queue();
            synchQ       = Queue.Synchronized(messageQueue);

            using (DataTable tbl = DbProviderFactories.GetFactoryClasses())
            {
                foreach (DataRow row in tbl.Rows)
                {
                    string prov = row[2].ToString();

                    /*if (prov.IndexOf("SQLite", 0, StringComparison.OrdinalIgnoreCase) != -1
                    || prov.IndexOf("SqlClient", 0, StringComparison.OrdinalIgnoreCase) != -1
                    || )
                    ||  _provider.Items.Add(prov);*/
                    if (prov == "CSLibrary.Data.SQLite")
                    {
                        _fact = DbProviderFactories.GetFactory(prov);
                        break;
                    }
                }
            }

            _cnn = _fact.CreateConnection();
            _cnn.ConnectionString       = databaseName;
            _cnnstring                  = _fact.CreateConnectionStringBuilder();
            _cnnstring.ConnectionString = databaseName;
        }
Ejemplo n.º 18
0
        private DbProviders()
        {
            List <Type> insertTypes =
                Assembly.GetExecutingAssembly().GetTypes().Where(
                    t =>
                    t.BaseType == typeof(BulkLoader) &&
                    t.GetCustomAttributes(typeof(LoaderAttribute), true).Length > 0).ToList();

            foreach (DataRow prov in DbProviderFactories.GetFactoryClasses().Rows)
            {
                string invariant = (string)prov["InvariantName"];
                try
                {
                    Type type =
                        insertTypes.Find(
                            t =>
                            ((LoaderAttribute)t.GetCustomAttributes(typeof(LoaderAttribute), true)[0]).
                            ProviderInvariantName == invariant);
                    if (type != null)
                    {
                        Add(new DbProviderInfo(prov)
                        {
                            BulkInsertType = type
                        });
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error adding provider {0}:\r\n{1}", invariant, ex.Message);
                }
            }
        }
Ejemplo n.º 19
0
        public string GetProviderFactoryClasses()
        {
            // Retrieve the installed providers and factories.
            DataTable table = DbProviderFactories.GetFactoryClasses();
            string    ret   = null;
            int       i     = 0;
            int       j     = 0;

            try
            {
                j = 1;
                foreach (DataRow row in table.Rows)
                {
                    i = 0;
                    foreach (DataColumn column in table.Columns)
                    {
                        //column = column_loopVariable;
                        i   = i + 1;
                        ret = ret + (i == 1 ? string.Format("[{0}] {1} ", j, row[column]) : i == 3 ? string.Format("  |  {0}", row[column]) : "");
                    }
                    ret = ret + Environment.NewLine;
                    j   = j + 1;
                }
            }
            catch (Exception ex)
            {
                logger.Log(LogLevel.Error, "[GetProviderFactoryClasses] " + ex.Message);
            }
            return(ret);
        }
Ejemplo n.º 20
0
        public static DataTable GetAvailableDB()
        {
            DataTable dt = DbProviderFactories.GetFactoryClasses();

            dt.Rows.Add(new object[] { "SQLite Data Provider", ".Net Framework Data Provider for SQLite", SQLiteName, "System.Data.SQLite.SQLiteFactory, System.Data.SQLite" });
            return(dt);
        }
Ejemplo n.º 21
0
        public static void Configure()
        {
            if (!configured)
            {
                lock (syncRoot)
                {
                    if (!configured)
                    {
                        foreach (var cs in Utils.ConfigurationManager.GetSettings <DbProviderFactoryCustom>("DbProviderFactories"))
                        {
                            DbProviderFactories.RegisterFactory(cs.Invariant, cs.Type);
                        }

                        var factories = DbProviderFactories.GetFactoryClasses();
                        AppDomain.CurrentDomain.SetData("DataDirectory", AppDomain.CurrentDomain.BaseDirectory); //SQLite

                        foreach (var cs in Utils.ConfigurationManager.ConnectionStrings)
                        {
                            var factory = factories.Rows.Find(cs.ProviderName);
                            if (factory == null)
                            {
                                throw new ConfigurationErrorsException("Db factory " + cs.ProviderName + " not found.");
                            }
                            RegisterDatabase(cs.Name, cs);
                        }
                        configured = true;
                    }
                }
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Create a dynamic model
        /// </summary>
        /// <param name="connectionStringName">the connection string name or the connection stirng itself</param>
        /// <param name="tableName">the table name</param>
        /// <param name="primaryKeyField">the primary key field name</param>
        public DynamicModel(string connectionStringName, string tableName = "", string primaryKeyField = "")
        {
            TableName       = string.IsNullOrEmpty(tableName) ? GetType().Name : tableName;
            PrimaryKeyField = string.IsNullOrEmpty(primaryKeyField) ? "ID" : primaryKeyField;

            try
            {
                _factory = DbProviderFactories.GetFactory(ProviderName);
            }
            catch (FileLoadException ex)
            {
                throw new MassiveException(string.Format("Could not load the specified provider: {0}. Have you added a reference to the correct assembly?", ProviderName), ex);
            }
            catch (ArgumentException e)
            {
                var foundClasses = "I did find these Factories:";
                var dt           = DbProviderFactories.GetFactoryClasses();
                for (var i = 0; i < dt.Rows.Count; i++)
                {
                    foundClasses += String.Format("|{0}|", dt.Rows[i][2]);
                }

                throw new ArgumentException(String.Format("{0}{1}{2}", e.Message, Environment.NewLine, foundClasses));
            }

            var conString = ConfigurationManager.ConnectionStrings[connectionStringName];

            _connectionString = conString != null ? conString.ConnectionString : connectionStringName;
        }
        /// <summary>
        ///   Obtiene la factoría del proveedor de datos especificado en la cadena de conexión.
        /// </summary>
        /// <param name="connectionStringSettings">La configuración de la cadena de conexión.</param>
        /// <returns><see cref="DbProviderFactory"/> relacionado con la cadena de conexión.</returns>
        public static DbProviderFactory GetDbProviderFactory(this ConnectionStringSettings connectionStringSettings)
        {
            if (connectionStringSettings == null)
            {
                throw new ArgumentNullException("connectionStringSettings");
            }

            // Comprobar que se ha especificado el nombre del proveedor de datos.
#if NET35
            if ((connectionStringSettings.ProviderName == null) || (connectionStringSettings.ProviderName.Trim().Length == 0))
#else
            if (String.IsNullOrWhitespace(connectionStringSettings.ProviderName))
#endif
            { throw new ConfigurationErrorsException(
                        "",
                        connectionStringSettings.ElementInformation.Source,
                        connectionStringSettings.ElementInformation.LineNumber); }

            // Comprobar que el nombre del proveedor de datos es válido.
            if (DbProviderFactories.GetFactoryClasses().Rows.Find(connectionStringSettings.ProviderName) == null)
            {
                throw new ConfigurationErrorsException(
                          "",
                          connectionStringSettings.ElementInformation.Source,
                          connectionStringSettings.ElementInformation.LineNumber);
            }

            // Obtenemos y devolvemos la factoría para el proveedor de datos.
            return(DbProviderFactories.GetFactory(connectionStringSettings.ProviderName));
        }
Ejemplo n.º 24
0
        protected override void InitializeTarget()
        {
            base.InitializeTarget();

            bool foundProvider = false;

#if !NET_CF
            if (!string.IsNullOrEmpty(this.ConnectionStringName))
            {
                // read connection string and provider factory from the configuration file
                var cs = this.ConnectionStringsSettings[this.ConnectionStringName];
                if (cs == null)
                {
                    throw new NLogConfigurationException("Connection string '" + this.ConnectionStringName + "' is not declared in <connectionStrings /> section.");
                }

                this.ConnectionString = SimpleLayout.Escape(cs.ConnectionString);
                this.ProviderFactory  = DbProviderFactories.GetFactory(cs.ProviderName);
                foundProvider         = true;
            }

            if (!foundProvider)
            {
                foreach (DataRow row in DbProviderFactories.GetFactoryClasses().Rows)
                {
                    if ((string)row["InvariantName"] == this.DBProvider)
                    {
                        this.ProviderFactory = DbProviderFactories.GetFactory(this.DBProvider);
                        foundProvider        = true;
                    }
                }
            }
#endif

            if (!foundProvider)
            {
                switch (this.DBProvider.ToUpper(CultureInfo.InvariantCulture))
                {
                case "SQLSERVER":
                case "MSSQL":
                case "MICROSOFT":
                case "MSDE":
                    this.ConnectionType = systemDataAssembly.GetType("System.Data.SqlClient.SqlConnection", true);
                    break;

                case "OLEDB":
                    this.ConnectionType = systemDataAssembly.GetType("System.Data.OleDb.OleDbConnection", true);
                    break;

                case "ODBC":
                    this.ConnectionType = systemDataAssembly.GetType("System.Data.Odbc.OdbcConnection", true);
                    break;

                default:
                    this.ConnectionType = Type.GetType(this.DBProvider, true);
                    break;
                }
            }
        }
Ejemplo n.º 25
0
        private void Factories_Load(object sender, EventArgs e)
        {
            // GetFactoryClasses returns a DataTable that contains information about all installed
            // providers that implement DbProviderFactory.
            DataTable providers = DbProviderFactories.GetFactoryClasses();

            provList.DataSource = providers;
        }
Ejemplo n.º 26
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            DebugToFile("MainForm_Load::Begin");

            if (mainForm != this)
            {
                return;
            }

            ExpressionEvaluation.FunctionEval.AdditionalFunctionEvent += this.FunctionEval_AdditionalFunctionEvent;

            var msg = new StringBuilder();

            msg.Append("====== Available functions: ======");
            msg.AppendLine();

            foreach (var customFunction in this.functions)
            {
                msg.Append("# ");
                msg.Append(customFunction.Description);
                msg.AppendLine();

                msg.AppendFormat(
                    "{0} ({1}) => {2}",
                    customFunction.Name,
                    string.Join(", ", customFunction.ParametersNames.Select(x => "<" + x + ">")),
                    customFunction.ReturnType
                    );
                msg.AppendLine();

                msg.AppendLine();
            }

            msg.Append("==================================");
            msg.AppendLine();

            msg.Append("====== DbProviderFactories: ======");
            msg.AppendLine();

            var dt = DbProviderFactories.GetFactoryClasses();

            foreach (DataRow row in dt.Rows)
            {
                foreach (DataColumn col in dt.Columns)
                {
                    msg.AppendFormat("{0}=[{1}] ", col.ColumnName, row[col.ColumnName]);
                }

                msg.AppendLine();
            }

            msg.Append("==================================");
            msg.AppendLine();

            this.WriteDebug(msg, false, false);

            DebugToFile("MainForm_Load::End");
        }
Ejemplo n.º 27
0
        public static void Main(string[] args)
        {
            using (DataTable providers = DbProviderFactories.GetFactoryClasses())
            {
                var prov = providers.Rows;
            }

            CreateWebHostBuilder(args).Build().Run();
        }
Ejemplo n.º 28
0
 public void GetProviderFactory_for_generic_connection_should_return_correct_generic_factory_on_net40()
 {
     Assert.NotNull(GenericProviderFactory <DbProviderFactory> .Instance);
     Assert.Equal(
         GenericProviderFactory <DbProviderFactory> .Instance,
         new Net40DefaultDbProviderFactoryService(
             new ProviderRowFinder()).GetProviderFactory(
             new GenericConnection <DbProviderFactory>(), DbProviderFactories.GetFactoryClasses().Rows.OfType <DataRow>()));
 }
Ejemplo n.º 29
0
        public void LoadProviders()
        {
            // Retrieve the installed providers and factories.
            DataTable table = DbProviderFactories.GetFactoryClasses();

            comboProviders.DisplayMemberPath = "Name";
            comboProviders.SelectedValuePath = "InvariantName";
            comboProviders.ItemsSource       = table.DefaultView;
        }
Ejemplo n.º 30
0
        public static void ListAdoNetProvider()
        {
            DataTable factories = DbProviderFactories.GetFactoryClasses();

            foreach (DataRow row in factories.Rows)
            {
                // ...
            }
        }