Need on the best way to going about programming this in c#. I'm trying to do an if record exists update statement else insert statement:
OracleConnection con = new OracleConnection(strConnection);
con.Open();
OracleCommand check_RID = new OracleCommand("SELECT COUNT(*) FROM CONTRACT_INFO WHERE (rid = @rid)", con);
check_RID.Parameters.Add("@rid", labelRID.Text);
OracleDataReader reader = check_RID.ExecuteReader();
if (reader.HasRows)
{
OracleConnection conn = new OracleConnection(); // C#
conn.ConnectionString = strConnection;
conn.Open();
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
cmd.CommandText = "UPDATE...
cmd.ExecuteNonQuery();
conn.Close();
Response.Redirect("primecontractor.aspx?Id=" + labelRID.Text);
}
else
{
OracleConnection conn = new OracleConnection(); // C#
conn.ConnectionString = strConnection;
conn.Open();
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
cmd.CommandText = "INSERT....
......
cmd.ExecuteNonQuery();
conn.Close();
Is there a better way to program this and if so how?