int MSOracleClient() { System.Data.OracleClient.OracleConnectionStringBuilder connBuilder = new System.Data.OracleClient.OracleConnectionStringBuilder(); connBuilder.DataSource = txtDataSource.Text.Trim(); connBuilder.UserID = txtUserId.Text.Trim(); connBuilder.Password = txtPwd.Text.Trim(); connBuilder.LoadBalanceTimeout = 60; connBuilder.MinPoolSize = 0; connBuilder.MaxPoolSize = 50; int rows = 0; using (System.Data.OracleClient.OracleConnection conn = new System.Data.OracleClient.OracleConnection(connBuilder.ConnectionString)) { //System.Data.OracleClient.OracleConnection conn = new System.Data.OracleClient.OracleConnection(connBuilder.ConnectionString); System.Data.OracleClient.OracleCommand cmd = conn.CreateCommand(); cmd.CommandText = txtSql.Text.Trim(); cmd.CommandTimeout = 300; //cmd.ResetCommandTimeout(); conn.Open(); using (System.Data.OracleClient.OracleDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { object[] objs = new object[500]; dr.GetValues(objs); rows++; } } return(rows); } }
int DevartOracleClient() { System.Data.OracleClient.OracleConnectionStringBuilder connBuilder = new System.Data.OracleClient.OracleConnectionStringBuilder(); connBuilder.DataSource = txtDataSource.Text.Trim(); connBuilder.UserID = txtUserId.Text.Trim(); connBuilder.Password = txtPwd.Text.Trim(); int rows = 0; using (Devart.Data.Oracle.OracleConnection conn = new Devart.Data.Oracle.OracleConnection(connBuilder.ConnectionString)) { Devart.Data.Oracle.OracleCommand cmd = conn.CreateCommand(); cmd.CommandText = txtSql.Text.Trim(); cmd.CommandTimeout = 300; conn.Open(); using (Devart.Data.Oracle.OracleDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { object[] objs = new object[500]; dr.GetValues(objs); rows++; } } return(rows); } }
internal static void Do() { SqlConnectionStringBuilder sqlConnSb = new SqlConnectionStringBuilder(); sqlConnSb.DataSource = @"NSIMPLE-P4MAN\SQLEXPRESS"; sqlConnSb.InitialCatalog = "Northwind"; sqlConnSb.IntegratedSecurity = true; SqlConnection cn = new SqlConnection(sqlConnSb.ConnectionString); cn.Open(); Console.WriteLine(sqlConnSb.ConnectionString); Console.WriteLine(cn.State); Console.WriteLine(); Console.WriteLine("OracleConnectionStringBuilder"); string ostr = "Data Source=myOracle;User Id=myUsername;Password=myPassword;Min Pool Size=10;Connection Lifetime=120;"; OracleConnectionStringBuilder oraConnSb = new OracleConnectionStringBuilder(ostr); Console.WriteLine(oraConnSb.ConnectionString); Console.WriteLine(oraConnSb.DataSource); Console.WriteLine(oraConnSb.UserID); Console.WriteLine(oraConnSb.Password); Console.WriteLine(oraConnSb.MinPoolSize); Console.WriteLine(oraConnSb.LoadBalanceTimeout); Console.WriteLine("=========================="); Console.WriteLine(); }
public static OracleConnection getConnection() { if (oracleConnection1 == null) { OracleConnectionStringBuilder myCStringB = new OracleConnectionStringBuilder(); myCStringB.UserID = "CinemaCity2"; myCStringB.Password = "******"; myCStringB.DataSource = "XE"; oracleConnection1 = new OracleConnection(myCStringB.ConnectionString); } return oracleConnection1; }
/// <summary> /// 设置数据库属性 /// </summary> /// <param name="forDatabase">数据库实例</param> /// <returns>数据库属性</returns> protected override DbProperties GetPropertiesFromDb(Database forDatabase) { string sql = "Select PRODUCT ,VERSION ,STATUS FROM Product_component_version where substr(product,1,6)='Oracle' "; //"SELECT SERVERPROPERTY('productversion') AS [version], SERVERPROPERTY ('productlevel') AS [level], SERVERPROPERTY ('edition') AS [edition]"; DbProperties props = null; System.Data.OracleClient.OracleConnectionStringBuilder builder = new System.Data.OracleClient.OracleConnectionStringBuilder(forDatabase.ConnectionString); string dbname = builder.UserID; Dictionary <string, object> dict = forDatabase.ExecuteReadDict(sql); props = new DbProperties(dbname, "Oracle", dict["VERSION"].ToString(), dict["STATUS"].ToString(), dict["PRODUCT"].ToString(), true, "||", _sqlToken, ".", "TO_DATE('{0}', 'YYYY-MM-DD HH24:MI:SS')", "SYS_GUID()", "sysdate", "SUBSTR", "nvl", "length"); return(props); }
public static string getConnString(ConnStringType type) { string connString = String.Empty; switch(type){ case ConnStringType.Oracle: OracleConnectionStringBuilder oraConnBuilder = new OracleConnectionStringBuilder(); oraConnBuilder.DataSource = "141.218.103.112:1521/orcl"; oraConnBuilder.IntegratedSecurity = false; oraConnBuilder.UserID = userId; oraConnBuilder.Password = password; connString = oraConnBuilder.ConnectionString; break; case ConnStringType.MsSql: break; } return connString; }
public ConnectionStringParser(DbConnectionConfig dbConnectionConfig) { DbProvider dbProvider = dbConnectionConfig.DbProvider; string connectionString = dbConnectionConfig.ConnectionString; switch (dbProvider) { case DbProvider.MySql: { throw new NotImplementedException(); } case DbProvider.Teradata: { throw new NotImplementedException(); } case DbProvider.Sqlite: { throw new NotImplementedException(); } case DbProvider.SqlServer: { SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(connectionString); DataSource = builder.DataSource; UserID = builder.UserID; Password = builder.Password; } break; case DbProvider.Oracle: { OracleConnectionStringBuilder builder = new OracleConnectionStringBuilder(connectionString); DataSource = builder.DataSource; UserID = builder.UserID; Password = builder.Password; } break; case DbProvider.OleDb: { OleDbConnectionStringBuilder builder = new OleDbConnectionStringBuilder(connectionString); DataSource = builder.DataSource; UserID = builder["UserID"].ToString(); Password = builder["Password"].ToString(); } break; } }
#pragma warning disable 612, 618 IDatabaseOracleConfiguration IDatabaseOracleConfiguration.WithConnectionString(OracleConnectionStringBuilder builder) { base.WithConnectionString(builder); return this; }
/// <summary>Damの選択</summary> private void cmbDataProvider_SelectedIndexChanged(object sender, EventArgs e) { try { // 初期は、無効にして、ODP.NET、HiRDB選択時のみ有効にする。 this.nudNumOfBind.Enabled = false; if (this.cmbDataProvider.SelectedItem.ToString() == Literal.DAP_SQL) { //sqlClient this._dam = new DamSqlSvr(); //接続文字列のサンプルを設定する(空の場合)。 SqlConnectionStringBuilder csb = new SqlConnectionStringBuilder(); csb.DataSource = this._ip; csb.InitialCatalog = "Northwind"; csb.UserID = this._uid; csb.Password = this._pwd; this.txtCnnStr.Text = csb.ConnectionString; // 状態 ((ToolStripStatusLabel)this.statBar.Items[0]).Text = this.RM_GetString("STATUS_SQL_CREATED"); } else if (this.cmbDataProvider.SelectedItem.ToString() == Literal.DAP_OLE) { //OLEDB.NET this._dam = new DamOLEDB(); //接続文字列のサンプルを設定する(空の場合)。 OleDbConnectionStringBuilder csb = new OleDbConnectionStringBuilder(); csb.Provider = "Provider"; csb.DataSource = "DataSourceName"; csb.FileName = "FileName"; this.txtCnnStr.Text = csb.ConnectionString; // 活性 this.nudNumOfBind.Enabled = true; // 状態 ((ToolStripStatusLabel)this.statBar.Items[0]).Text = this.RM_GetString("STATUS_OLE_CREATED"); } if (this.cmbDataProvider.SelectedItem.ToString() == Literal.DAP_ODB) { //ODBC.NET this._dam = new DamODBC(); //接続文字列のサンプルを設定する(空の場合)。 OdbcConnectionStringBuilder csb = new OdbcConnectionStringBuilder(); csb.Driver = "DriverName"; csb.Dsn = "DataSourceName"; this.txtCnnStr.Text = csb.ConnectionString; // 活性 this.nudNumOfBind.Enabled = true; // 状態 ((ToolStripStatusLabel)this.statBar.Items[0]).Text = this.RM_GetString("STATUS_ODB_CREATED"); } if (this.cmbDataProvider.SelectedItem.ToString() == Literal.DAP_ORA) { //Oracle Client this._dam = new DamOraClient(); //接続文字列のサンプルを設定する(空の場合)。 System.Data.OracleClient.OracleConnectionStringBuilder csb = new System.Data.OracleClient.OracleConnectionStringBuilder(); csb.DataSource = this._ip + "/orcl"; csb.UserID = this._uid; csb.Password = this._pwd; this.txtCnnStr.Text = csb.ConnectionString; // 活性 this.nudNumOfBind.Enabled = true; // 状態 ((ToolStripStatusLabel)this.statBar.Items[0]).Text = this.RM_GetString("STATUS_ODP_CREATED"); } if (this.cmbDataProvider.SelectedItem.ToString() == Literal.DAP_ODP) { //ODP.NET this._dam = new DamOraOdp(); //接続文字列のサンプルを設定する(空の場合)。 Oracle.DataAccess.Client.OracleConnectionStringBuilder csb = new Oracle.DataAccess.Client.OracleConnectionStringBuilder(); csb.DataSource = this._ip + "/orcl"; csb.UserID = this._uid; csb.Password = this._pwd; this.txtCnnStr.Text = csb.ConnectionString; // 活性 this.nudNumOfBind.Enabled = true; // 状態 ((ToolStripStatusLabel)this.statBar.Items[0]).Text = this.RM_GetString("STATUS_ODP_CREATED"); } else if (this.cmbDataProvider.SelectedItem.ToString() == Literal.DAP_DB2) { //DB2.NET this._dam = new DamDB2(); //接続文字列のサンプルを設定する(空の場合)。 DB2ConnectionStringBuilder csb = new DB2ConnectionStringBuilder(); //csb.Server = this._ip + ":50000"; csb.Database = "SAMPLE"; csb.UserID = this._uid; csb.Password = this._pwd; this.txtCnnStr.Text = csb.ConnectionString; // 状態 ((ToolStripStatusLabel)this.statBar.Items[0]).Text = this.RM_GetString("STATUS_DB2_CREATED"); } //else if (this.cmbDataProvider.SelectedItem.ToString() == Literal.DAP_HiRDB) //{ // //HiRDBデータ プロバイダ // this._dam = new DamHiRDB(); // //接続文字列のサンプルを設定する(空の場合)。 // //HiRDBデータ プロバイダは、ConnectionStringBuilderがない。 // string csb = ""; // csb += "DataSource=C:\\Windows\\HiRDB.ini;"; // csb += "UID=" + this._uid + ";"; // csb += "PWD=" + this._pwd + ";"; // this.txtCnnStr.Text = csb; // // 活性 // this.nudNumOfBind.Enabled = true; // // 状態 // ((ToolStripStatusLabel)this.statBar.Items[0]).Text = Literal.STATUS_HRD_CREATED; //} else if (this.cmbDataProvider.SelectedItem.ToString() == Literal.DAP_MySQL) { //MySQL Connector/NET this._dam = new DamMySQL(); //接続文字列のサンプルを設定する(空の場合)。 MySqlConnectionStringBuilder csb = new MySqlConnectionStringBuilder(); csb.Server = this._ip; csb.Database = "test"; csb.UserID = this._uid; csb.Password = this._pwd; this.txtCnnStr.Text = csb.ConnectionString; // 状態 ((ToolStripStatusLabel)this.statBar.Items[0]).Text = this.RM_GetString("STATUS_MSL_CREATED"); } else if (this.cmbDataProvider.SelectedItem.ToString() == Literal.DAP_PstgrS) { //Npgsql this._dam = new DamPstGrS(); //接続文字列のサンプルを設定する(空の場合)。 //NpgsqlConnectionStringBuilderは、冗長な接続文字列を返すので使わない。 //NpgsqlConnectionStringBuilder csb = new NpgsqlConnectionStringBuilder(); string csb = ""; //csb.Host = this._ip; //csb.Database = "postgres"; //csb.UserName = this._uid; //csb.Password = this._pwd; csb += "HOST=" + this._ip + ";"; csb += "DATABASE=postgres;"; csb += "UID=" + this._uid + ";"; csb += "PWD=" + this._pwd + ";"; this.txtCnnStr.Text = csb; // 状態 ((ToolStripStatusLabel)this.statBar.Items[0]).Text = this.RM_GetString("STATUS_PGS_CREATED"); } else { //ありえない } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public bool Open() { try { OracleConnectionStringBuilder builder = new OracleConnectionStringBuilder(); cnn.ConnectionString = "Server=localhost; User ID=root; Password="; cnn.Open(); return true; } catch (Exception e) { Console.Write(e.Message); return false; } }
private InstanceDescriptor ConvertToInstanceDescriptor(OracleConnectionStringBuilder options) { Type[] types = new Type[] { typeof(string) }; return(new InstanceDescriptor(typeof(OracleConnectionStringBuilder).GetConstructor(types), new object[] { options.ConnectionString })); }
private InstanceDescriptor ConvertToInstanceDescriptor(OracleConnectionStringBuilder options) { Type[] types = new Type[] { typeof(string) }; return new InstanceDescriptor(typeof(OracleConnectionStringBuilder).GetConstructor(types), new object[] { options.ConnectionString }); }
public OracleMetadataReader(string connectionStr) { this.connectionStr = connectionStr; OracleConnectionStringBuilder connStr = new OracleConnectionStringBuilder(connectionStr); DatabaseName = connStr.DataSource; }