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); }
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); }
/// <summary> /// RSS사이트의 idx를 설정(title, url필요) /// </summary> /// <param name="user_id"></param> public void setSiteIdx(string user_id) { System.Data.DataSet DS = new System.Data.DataSet(); System.Data.SqlClient.SqlConnection dbCon; string QUERY = "SELECT idx FROM tb_RSSsite WHERE user_id='" + user_id + "' AND RSS_name='" + objUtil.toDb(siteTitle) + "' AND RSS_url='" + siteURL + "' AND RSS_state='AA'"; dbCon = objDB.GetConnection(); DS = objDB.ExecuteDSQuery(dbCon, QUERY); dbCon.Close(); if (objCmnDB.validateDS(DS)) { idx = DS.Tables[0].Rows[0][0].ToString(); } else { idx = ""; } }