public string INSERT_DB(System.Data.SqlClient.SqlConnection dbCon, System.Data.SqlClient.SqlTransaction TRX, string tbName, string cols, string vals) { int i; string Result = ""; StringBuilder strBuilder = new StringBuilder(); System.Collections.ArrayList arrCols = new System.Collections.ArrayList(); System.Collections.ArrayList arrVals = new System.Collections.ArrayList(); arrCols.AddRange(objUtil.Split(cols, "|")); arrVals.AddRange(objUtil.Split(vals, "|")); strBuilder.Append("INSERT INTO " + tbName); strBuilder.Append(" ("); for (i = 0; i < arrCols.Count; i++) { if (i > 0) { strBuilder.Append(", "); } strBuilder.Append(objUtil.toDb(arrCols[i].ToString())); } strBuilder.Append(") VALUES ("); for (i = 0; i < arrVals.Count; i++) { if (i > 0) { strBuilder.Append(", "); } strBuilder.Append("'"); strBuilder.Append(objUtil.toDb(arrVals[i].ToString().Replace("%/", "|"))); strBuilder.Append("'"); } strBuilder.Append(")"); objUtil.writeLog("INSERT_DB QUERY : " + strBuilder.ToString()); try { Result = objDB.ExecuteNonQuery(dbCon, TRX, strBuilder.ToString()); } catch (Exception e) { objUtil.writeLog("ERR CMN INSERT [" + tbName + "] " + "[" + cols + "] " + "[" + vals + "]"); objUtil.writeLog("ERR CMN INSERT QUERY : " + strBuilder.ToString()); objUtil.writeLog("ERR CMN INSERT MSG : " + e.ToString()); Result = "FAIL"; } return(Result); }
public string DELETE_DB(System.Data.SqlClient.SqlConnection dbCon, System.Data.SqlClient.SqlTransaction TRX, string tbName, string Wcols, string Wvals) { int i; string Result = ""; StringBuilder strBuilder = new StringBuilder(); libCommon.clsDB objDB = new libCommon.clsDB(); libCommon.clsUtil objUtil = new libCommon.clsUtil(); System.Collections.ArrayList arrWCols = new System.Collections.ArrayList(); System.Collections.ArrayList arrWVals = new System.Collections.ArrayList(); arrWCols.AddRange(objUtil.Split(Wcols, "|")); arrWVals.AddRange(objUtil.Split(Wvals, "|")); strBuilder.Append("DELETE FROM " + tbName); strBuilder.Append(" WHERE "); for (i = 0; i < arrWCols.Count; i++) { if (i > 0) { strBuilder.Append(" AND "); } strBuilder.Append("["); strBuilder.Append(objUtil.toDb(arrWCols[i].ToString())); strBuilder.Append("]"); strBuilder.Append(" = "); strBuilder.Append("'"); strBuilder.Append(objUtil.toDb(arrWVals[i].ToString())); strBuilder.Append("'"); } try { Result = objDB.ExecuteNonQuery(dbCon, TRX, strBuilder.ToString()); } catch (Exception e) { objUtil.writeLog("ERR CMN DELETE [" + tbName + "] " + "[" + Wcols + "] " + "[" + Wvals + "]"); objUtil.writeLog("ERR CMN DELETE QUERY : " + strBuilder.ToString()); objUtil.writeLog("ERR CMN DELETE MSG : " + e.ToString()); Result = "FAIL"; } return(Result); }