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); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tstBtn_Click(object sender, EventArgs e) { tstBtn.Enabled = false; if (rdBtn_devart.Checked) { var connectionStringBuilder = new Devart.Data.Oracle.OracleConnectionStringBuilder(); connectionStringBuilder.Direct = true; connectionStringBuilder.ServiceName = txtBx_serviceName.Text; connectionStringBuilder.Sid = txtBx_sid.Text; connectionStringBuilder.Server = txtBx_server.Text; connectionStringBuilder.Port = Int32.Parse(txtBx_port.Text); connectionStringBuilder.UserId = txtBx_user.Text; connectionStringBuilder.Password = txtBx_pass.Text; var connection = new Devart.Data.Oracle.OracleConnection(connectionStringBuilder.ConnectionString); if (connection != null) { for (int i = 0; i <= Int32.Parse(txtBx_qtd.Text); i++) { if (connection.State != ConnectionState.Open) { connection.Open(); MessageBox.Show("Conexão estabelecida"); } Thread.Sleep(5000); connection.Close(); MessageBox.Show("Conexão encerrada"); Thread.Sleep(3000); } } } else if (rdBtn_native.Checked) { var connectionStringBuilder = new OracleConnectionStringBuilder(); connectionStringBuilder.DataSource = txtBx_sid.Text; connectionStringBuilder.UserID = txtBx_user.Text; connectionStringBuilder.Password = txtBx_pass.Text; var connectionOracleClient = new OracleConnection(connectionStringBuilder.ConnectionString); if (connectionOracleClient != null) { for (int i = 0; i <= Int32.Parse(txtBx_qtd.Text); i++) { if (connectionOracleClient.State != ConnectionState.Open) { connectionOracleClient.Open(); MessageBox.Show("Conexão estabelecida"); } Thread.Sleep(5000); connectionOracleClient.Close(); MessageBox.Show("Conexão encerrada"); Thread.Sleep(3000); } } } else { MessageBox.Show("Selecione uma opção de driver."); } tstBtn.Enabled = true; }