方法一
/// 查询记录序号并加1
{
//记录序号
int r = 0;
string t = "";
OracleCommand cmd = null;
cmd = new OracleCommand();
cmd.Connection = conn;
cmd.CommandText = strSq1;
conn.Open();
object obj = cmd.ExecuteScalar();
if (obj != null)
{
t = obj.ToString();
r = Convert.ToInt32(t);
r++;
}
conn.Close();
cmd.Dispose();
return r;
}
/// 加1后修改记录序号
public void RecnoUpdate(string strSq2)
{
OracleCommand cmd = null;
cmd = new OracleCommand();
cmd.Connection = conn;
cmd.CommandText = strSq2;
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
cmd.Dispose();
}
string strSq1 = "Select RECORD1 From T_RECORD";
int r = operate.RecnoSelect(strSq1);
string strSq2 = String.Format("Update T_RECORD Set RECORD1 ='{0}'", r);
operate.RecnoUpdate(strSq2);
方法二
INSERTINTO T_table (Record_no)Values(s_zg_operation.nextval);