public void InsertQuery(string sql) { InitDB(); g_OraTransaction = g_OraConnection.BeginTransaction(); g_OraCommand.CommandText = sql; g_OraCommand.ExecuteNonQuery(); g_OraTransaction.Commit(); //END }
public void VINInsert() { { try { string VIN = HttpUtility.UrlDecode(Context.Request["VIN"]); string VehicleKind = HttpUtility.UrlDecode(Context.Request["VehicleKind"]); string VehicleModel = HttpUtility.UrlDecode(Context.Request["VehicleModel"]); string VehicleModelNo = HttpUtility.UrlDecode(Context.Request["VehicleModelNo"]); string User = HttpUtility.UrlDecode(Context.Request["User"]); string Phone = HttpUtility.UrlDecode(Context.Request["Phone"]); string Address = HttpUtility.UrlDecode(Context.Request["Address"]); string USERID = VIN + Common.CommonUtil.FullFillString(Common.CommonUtil.GetNextValue("SEQ_NC_USER_USERID").ToString(), 13); using (Oracle.ManagedDataAccess.Client.OracleTransaction tran = OracleHelper.GetOracleTransaction(OracleHelper.GetOracleConnection())) { int result = 0; try { string sqlStrVehicle = "INSERT INTO NC_JDCCLXXB(VIN,QCFL,BRAND,VEHICLEMODEL) VALUES('" + VIN + "','" + VehicleKind + "','" + VehicleModel + "','" + VehicleModelNo + "')"; result += OracleHelper.ExecuteNonQuery(tran, CommandType.Text, sqlStrVehicle); string sqlStrUser = "******"DATE\",RESULT) VALUES('" + USERID + "','" + User + "','" + Phone + "','" + Address + "','" + VIN + "','" + VehicleModelNo + "',TO_DATE('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','YYYY-MM-DD HH24:MI:SS'),'" + "1" + "')"; result += OracleHelper.ExecuteNonQuery(tran, CommandType.Text, sqlStrUser); tran.Commit(); Context.Response.Write(Success("录入成功")); } catch (Exception e) { tran.Rollback(); if (result == 0) { Context.Response.Write(Failure("车架号已存在")); } else if (result == 1) { Context.Response.Write(Failure("用户已存在")); } else { Context.Response.Write(Failure("未知错误")); } } } } catch (Exception e) { Context.Response.Write(Failure("未知错误!")); } } }