Exemplo n.º 1
0
        /// <summary>
        /// Provides a new connection
        /// </summary>
        /// <param name="type"></param>
        /// <param name="connectstring"></param>
        /// <param name="settings"></param>
        /// <returns></returns>
        public static IConnection getConnection(
            DBType type,
            string connectstring,
            ConnectionSettings settings)
        {
            switch (type)
            {
            case DBType.Ingres:
                return(new Plugins.SQLBased.Ingres.IngresConnection(
                           connectstring,
                           settings));

            case DBType.Postgres:
                return(new Plugins.SQLBased.Postgres.PostgresConnection(
                           connectstring,
                           settings));

            case DBType.Oracle:
                return(new Plugins.SQLBased.Oracle.OracleConnection(
                           connectstring,
                           settings));

            case DBType.MySQL:
                return(new Plugins.SQLBased.MySQL.MySQLConnection(
                           connectstring,
                           settings));

            case DBType.MSSQL:
                return(new Plugins.SQLBased.MSSQL.MSSQLConnection(
                           connectstring,
                           settings));

            case DBType.XML:
                return(new Plugins.Other.XML.XMLConnection(
                           connectstring,
                           settings));
            }

            throw new Exception("Something is terribly wrong...");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns a DB-specific connectionstring.
        /// </summary>
        /// <param name="type">DBType</param>
        /// <param name="host">The machine, the database is hosted on</param>
        /// <param name="database">Name of the database</param>
        /// <param name="user">Username for connection</param>
        /// <param name="password">Password</param>
        /// <returns>The DB-specific connectionstring</returns>
        public static string createConnectionString(
            DBType type,
            string host,
            string database,
            string user,
            string password)
        {
            switch (type)
            {
            case DBType.Ingres:
                Ingres.Client.IngresConnectionStringBuilder ingresCSB
                    = new Ingres.Client.IngresConnectionStringBuilder();
                ingresCSB.Server   = host;
                ingresCSB.Database = database;
                ingresCSB.UserID   = user;
                ingresCSB.Password = password;
                return(ingresCSB.ConnectionString);

            case DBType.Oracle:
                /* Unfortunately, the oracledriver of mono-1.2.5.1
                 * does not contain a OracleConnectionStringBuilder class, so
                 * this part failes to compile under mono.
                 * As a workaround for now, the connection string gets pieced
                 * together manually. Once, the appropriate class is present in
                 * mono, this part can be commented in again.
                 *
                 * System.Data.OracleClient.OracleConnectionStringBuilder oracleCSB
                 *  = new System.Data.OracleClient.OracleConnectionStringBuilder();
                 * oracleCSB.DataSource = host;
                 * oracleCSB.UserID = user;
                 * oracleCSB.Password = password;
                 * return oracleCSB.ConnectionString;
                 */
                return("Data Source=" + host
                       + ";User ID=" + user
                       + ";Password="******"Server = " + host
                       + "; User Id = " + user
                       + "; Password = "******"; Database = " + database
                       + "; Encoding = UNICODE;");
            }
            throw new Exception("Unknown database type encountered!");
        }
Exemplo n.º 3
0
 /// <summary>
 /// Provides a new connection
 /// </summary>
 /// <param name="type">DBType</param>
 /// <param name="connectstring">Connection String</param>
 /// <returns>ProduktivDB-Objectlayer</returns>
 public static IConnection getConnection(
     DBType type,
     string connectstring)
 {
     return(getConnection(type, connectstring, new ConnectionSettings()));
 }