Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="name">used to display and search</param>
        /// <param name="type"></param>
        /// <param name="connectionString"></param>
        /// <returns></returns>
        private static ConnectionProvider RegisterOleDb(string name, ConnectionProviderType type, string connectionString)
        {
            ConnectionProvider pvd = new OleDbConnectionProvider(name, type, connectionString);

            ConnectionProviderManager.Register(pvd);
            return(pvd);
        }
Пример #2
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="name">used to display and search</param>
 /// <param name="type"></param>
 /// <param name="connectionString"></param>
 /// <returns></returns>
 private static ConnectionProvider RegisterOleDb(string name, ConnectionProviderType type, string connectionString)
 {
     ConnectionProvider pvd = new OleDbConnectionProvider(name, type, connectionString);
     ConnectionProviderManager.Register(pvd);
     return pvd;
 }
Пример #3
0
        public static ConnectionProvider Register(string serverName, string connectionString)
        {
            DbConnectionStringBuilder conn = new DbConnectionStringBuilder();
            conn.ConnectionString = connectionString.ToLower();

            string providerName = "sqldb";
            object value;
            if (conn.TryGetValue("provider", out value))
            {
                if (value is string)
                    providerName = (string)value;
            }

            ConnectionProvider pvd = null;
            switch (providerName)
            {
                case "xmlfile":
                    pvd = new XmlDbConnectionProvider(serverName, connectionString);
                    break;

                case "riadb":                   //Remote Invoke Agent
                    pvd = new RiaDbConnectionProvider(serverName, connectionString);
                    break;

                case "Microsoft.ACE.OLEDB.12.0": //Excel 2010
                case "Microsoft.Jet.OLEDB.4.0":  //Excel 2007 or Access
                case "MySqlProv":                //MySql
                case "MSDAORA":                  //Oracle
                case "sqloledb":
                    pvd = new OleDbConnectionProvider(serverName, connectionString);
                    break;

                case "sqldb":                   //Sql Server
                    pvd = new SqlDbConnectionProvider(serverName, connectionString);
                    break;
            }

            if (pvd != null)
                Register(pvd);
            else
                throw new Exception($"invlaid connection string {connectionString}");

            return pvd;
        }