本文整理汇总了C#中System.Data.OracleClient.OracleCommand.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# OracleCommand.Dispose方法的具体用法?C# OracleCommand.Dispose怎么用?C# OracleCommand.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.OracleClient.OracleCommand
的用法示例。
在下文中一共展示了OracleCommand.Dispose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckUseAcademicPositionName
public bool CheckUseAcademicPositionName()
{
bool result = true;
OracleConnection conn = ConnectionDB.GetOracleConnection();
// Create the command
OracleCommand command = new OracleCommand("SELECT count(ACAD_NAME) FROM TB_ACADEMIC_POSITION WHERE ACAD_NAME = :ACAD_NAME ", conn);
// Add the parameters.
command.Parameters.Add(new OracleParameter("ACAD_NAME", ACAD_NAME));
try
{
if (conn.State != ConnectionState.Open)
{
conn.Open();
}
int count = (int)(decimal)command.ExecuteScalar();
if (count >= 1)
{
result = false;
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
command.Dispose();
conn.Close();
}
return result;
}
示例2: BlokkeerSegment
public bool BlokkeerSegment(int spoorNr, int segmentNr)
{
var cmds = new OracleCommand("BLOKKEERSEGMENT", conn);
cmds.CommandType = CommandType.StoredProcedure;
cmds.Parameters.Add("p_spoorNr", OracleType.Number).Value = spoorNr;
cmds.Parameters.Add("p_segmentNr", OracleType.Number).Value = segmentNr;
cmds.Parameters.Add("p_geslaagd_out", OracleType.Number, 1);
cmds.Parameters["p_geslaagd_out"].Direction = ParameterDirection.Output;
OpenVerbinding();
using (var da = new OracleDataAdapter(cmds))
{
cmds.ExecuteNonQuery();
}
//VERBINDING SLUITEN
conn.Close();
cmds.Dispose();
//RETURN VALUE
if (cmds.Parameters["p_geslaagd_out"].Value.ToString() == "1")
{
return true;
}
else
{
return false;
}
}
示例3: execQuery
public OracleDataReader execQuery(string sql)
{
OracleCommand cmd = new OracleCommand(sql);
OracleDataReader reader = null;
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
try
{
reader = cmd.ExecuteReader();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
cmd.Dispose();
}
return reader;
}
示例4: createPost
public void createPost(Member member)
{
try
{
String connstr = "Data source = studentoracle.students.ittralee.ie/orcl;User id = t00171832;Password=" + getPassword() + ";";
OracleConnection conn = new OracleConnection(connstr);
conn.Open();
string query = "insert into posts values('" + member.Username + "', '" + member.Email + "' , " + member.Phone + " , :BlobParameter , '" + member.Image + "' , '"
+ member.JoinDate + "' , " + member.MsgPrivate + " , '" + member.LastSeen + ")";
MessageBox.Show(query);
//insert the byte as oracle parameter of type blob
OracleParameter blobParameter = new OracleParameter();
blobParameter.OracleType = OracleType.Blob;
blobParameter.ParameterName = "BlobParameter";
blobParameter.Value = member.Image;
OracleCommand cmnd = new OracleCommand(query, conn);
cmnd.Parameters.Add(blobParameter);
cmnd.ExecuteNonQuery();
cmnd.Dispose();
conn.Close();
conn.Dispose();
}
catch (Exception ex)
{
}
}
示例5: ExecuteReader
public static OracleDataReader ExecuteReader(string sqlStr, List<OracleParameter> parListOracleParameters)
{
OracleDataReader oracleDataReader = null;
OracleConnection oracleConnection = new OracleConnection();
oracleConnection.ConnectionString = OracleHelper.connectStr;
try
{
if (oracleConnection.State != ConnectionState.Open)
{
oracleConnection.Open();
}
OracleCommand oracleCommand = new OracleCommand();
oracleCommand.Connection = oracleConnection;
oracleCommand.CommandText = sqlStr;
for (int i = 0; i < parListOracleParameters.Count; i++)
{
oracleCommand.Parameters.Add(parListOracleParameters[i]);
}
oracleDataReader = oracleCommand.ExecuteReader(CommandBehavior.CloseConnection);
oracleCommand.Dispose();
}
catch (Exception ex)
{
oracleDataReader.Close();
oracleConnection.Close();
throw ex;
}
return oracleDataReader;
}
示例6: lbuSearch_Click
protected void lbuSearch_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(txtSearchSeminarCitizen.Text))
{
notification.Attributes["class"] = "alert alert_danger";
notification.InnerHtml = "";
notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>แจ้งเตือน</strong></div>";
notification.InnerHtml += "<div> - กรุณากรอกรหัสบัตรประชาชนในช่องคำค้นหา</div>";
return;
}
else
{
notification.Attributes["class"] = "none";
notification.InnerHtml = "";
}
if (txtSearchSeminarCitizen.Text.Length < 13)
{
notification.Attributes["class"] = "alert alert_danger";
notification.InnerHtml = "";
notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>แจ้งเตือน</strong></div>";
notification.InnerHtml += "<div> - กรุณากรอกรหัสบัตรประชาชนในช่องค้นหาให้ครบ 13 หลัก</div>";
return;
}
else
{
notification.Attributes["class"] = "none";
notification.InnerHtml = "";
}
string result = "";
OracleConnection con2 = ConnectionDB.GetOracleConnection();
OracleCommand com2 = new OracleCommand("SELECT CITIZEN_ID FROM TB_SEMINAR WHERE CITIZEN_ID = '" + txtSearchSeminarCitizen.Text + "'", con2);
if (con2.State != ConnectionState.Open)
{
con2.Open();
}
OracleDataReader reader2 = com2.ExecuteReader();
while (reader2.Read())
{
result = reader2.GetString(0);
}
if (result != txtSearchSeminarCitizen.Text)
{
notification.Attributes["class"] = "alert alert_danger";
notification.InnerHtml = "";
notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>แจ้งเตือน</strong></div>";
notification.InnerHtml += "<div> - ไม่พบข้อมูลของรหัสบัตรประชาชนดังกล่าว</div>";
return;
}
com2.Dispose();
con2.Close();
}
示例7: clearError
public static void clearError(OracleSql db, int seqNo)
{
string version = getDatamodelVersion(db);
Int32 error_count = 0;
if (db.GetMetaConnection() != null)
{
string cmdQuery = "update " + sqlmakeRegistryTableName + " set path = 'CLEARED." + version + "', sdate_u=sysdate, suser_u='" + Environment.UserName + "@" + Environment.MachineName + "' where path = 'ERRORS." + version + "' and value = " + seqNo;
OracleCommand cmd = new OracleCommand(cmdQuery, db.GetMetaConnection());
error_count = cmd.ExecuteNonQuery();
cmd.Dispose();
}
if (error_count == 0) { Log.ExitError("No error to clear"); }
else Log.Info("clearError", "Error with sequence number {0} cleared", seqNo);
}
示例8: Execute
/// <summary>
/// ����
/// </summary>
/// <param name="sql"></param>
public static string Execute(string key, string sql, params OracleParameter[] pas)
{
string n;
OracleConnection conn = null;
OracleCommand cmd = null;
try
{
conn = GetConnection(key);
cmd = new OracleCommand();
cmd.Connection = conn;
conn.Open();
cmd.CommandText = sql;
cmd.Parameters.Clear();
OracleParameter[] clonedParameters = new OracleParameter[pas.Length];
//�⽫ִ��һ�������deep copy������������� ��Ȼ�����������ε�ʱ��ͻᱨ���
for (int i = 0, j = pas.Length; i < j; i++)
{
clonedParameters[i] = (OracleParameter)((ICloneable)pas[i]).Clone();
}
foreach (OracleParameter temppa in clonedParameters)
{
cmd.Parameters.Add(temppa);
}
cmd.ExecuteNonQuery();
n = cmd.Parameters[pas.Length - 1].Value.ToString();
}
catch (Exception e)
{
throw new DAOException(sql + "\n" + e.Message);
}
finally
{
try { cmd.Dispose(); conn.Close(); conn.Dispose(); }
catch { }
}
return n;
}
示例9: SetUp
public void SetUp()
{
Exception exp = null;
BeginCase("Setup");
try
{
//prepare Data
OracleCommand cmdPrepare = new OracleCommand("", new OracleConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString));
cmdPrepare.Connection.Open();
cmdPrepare.CommandText = "DELETE FROM Employees WHERE EmployeeID = 99999";
cmdPrepare.ExecuteScalar();
cmdPrepare.Connection.Close();
cmdPrepare.Dispose();
con = new OracleConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString);
cmd = new OracleCommand("", con);
con.Open();
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
}
示例10: DELETE_PS_DISCIPLINARY_AND_AMNESTY
public bool DELETE_PS_DISCIPLINARY_AND_AMNESTY()
{
bool result = false;
OracleConnection conn = ConnectionDB.GetOracleConnection();
OracleCommand command = new OracleCommand("Delete PS_DISCIPLINARY_AND_AMNESTY where PS_DAA_ID = :PS_DAA_ID", conn);
try {
if (conn.State != ConnectionState.Open) {
conn.Open();
}
command.Parameters.Add(new OracleParameter("PS_DAA_ID", PS_DAA_ID));
if (command.ExecuteNonQuery() >= 0) {
result = true;
}
} catch (Exception ex) {
throw ex;
} finally {
command.Dispose();
conn.Close();
}
return result;
}
示例11: DeleteBySql
//提交删除命令
public override string DeleteBySql(string strsql)
{
try
{
this.CheckConn();
OracleCommand cmdDel = new OracleCommand();
OracleDataAdapter daDel = new OracleDataAdapter();
int delrownum;
cmdDel.Connection = MyConn;
cmdDel.CommandText = strsql;
daDel.DeleteCommand = cmdDel;
delrownum = daDel.DeleteCommand.ExecuteNonQuery();
cmdDel.Dispose();
daDel.Dispose();
return ("ok");
}
catch (Exception ex)
{
return (ex.Message);
}
}
示例12: SetUp
public void SetUp()
{
Exception exp = null;
BeginCase("Setup");
try
{
con = new OracleConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString);
con.Open();
//prepare Data
OracleCommand cmdPrepare = new OracleCommand("", con);
cmdPrepare.CommandText = "DELETE FROM Employees WHERE EmployeeID = 99999";
cmdPrepare.ExecuteNonQuery();
cmdPrepare.CommandText = "INSERT INTO Employees (EmployeeID, FirstName, LastName) VALUES (99999,'OferXYZ', 'Testing')";
cmdPrepare.ExecuteNonQuery();
cmdPrepare.Dispose();
cmd = new OracleCommand("", con);
}
catch(Exception ex) {exp = ex;}
finally {EndCase(exp); exp = null;}
}
示例13: ExecuteNonQuery
public static string ExecuteNonQuery(string sql)
{
string ret = "false";
try
{
OracleCommand cmd = new OracleCommand();
cmd.Connection = GetConnection();
cmd.CommandText = sql;
cmd.CommandType = CommandType.Text;
cmd.CommandTimeout = 240;
int r = cmd.ExecuteNonQuery();
cmd.Connection.Close();
cmd.Dispose();
ret = "true";
}
catch (Exception ex)
{
ret = "false|Exception : " + ex.Message + Environment.NewLine + ex.StackTrace + Environment.NewLine + "&SQL=" + sql;
}
return ret;
}
示例14: get_table_fileds
/// <summary>
/// ��ȡ�����ֶ�ֵ
/// </summary>
/// <param name="table_name">����</param>
/// <param name="table_fileds">�ֶ�</param>
/// <param name="where_fileds">��ѯ�����ֶ�</param>
/// <param name="where_value">��ѯֵ</param>
/// <returns></returns>
public override string get_table_fileds(string table_name, string table_fileds, string where_fileds, string where_value)
{
where_value = Common.inSQL(where_value);
string rStr = "";
using (OracleConnection Conn = GetSqlConnection())
{
string strSql = string.Format("select {0} from {1} where upper({2})='{3}'", table_fileds, table_name.ToUpper(), where_fileds, where_value);
OracleCommand cmd = new OracleCommand(strSql, Conn);
cmd.CommandType = CommandType.Text;
Conn.Open();
OracleDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
rStr = dr[0].ToString();
}
dr.Close();
dr.Dispose();
cmd.Dispose();
Conn.Dispose();
Conn.Close();
}
return rStr;
}
示例15: AddData
public int AddData(string strSQL)
{
int intReturn = 0;
OracleConnection connection = null;
OracleCommand command = null;
try
{
connection = new OracleConnection(Connection.ConnectionString());
command = new OracleCommand();
command.CommandText = strSQL;
command.Connection = connection;
connection.Open();
int intRowAffected = command.ExecuteNonQuery();
connection.Close();
if (intRowAffected > 0)
{
return intReturn = intRowAffected;
}
else
{
return intReturn;
}
}
catch (Exception)
{
throw;
}
finally
{
if (command != null) command.Dispose();
if (connection != null && connection.State != ConnectionState.Closed) connection.Close();
}
return intReturn;
}