/// <summary>
/// Insert 쿼리 생성
/// </summary>
/// <param name="ht">인서트 내용: Key는 인서트할 필드명, Value는 인서트할 값을 넣어준다 </param>
/// <returns></returns>
public string CreateInsertQuery(string tableName, Hashtable ht)
{
string sql = string.Empty;
string field = string.Empty;
string values = string.Empty;
DateTime.Now.ToString("yyyyMMdd HH:mm:ss");
int x = 0;
// INSERT 문
foreach (DictionaryEntry de in ht)
{
if (x == 0)
{
field = (string)de.Key;
values = "'" + de.Value + "'";
}
else
{
field += ", " + de.Key;
values += ", '" + de.Value + "'";
}
x++;
}
sql = " INSERT INTO " + tableName + " (" + field + ") VALUES (" + values + ")";
return sql;
}
'.NET > SampleCode' 카테고리의 다른 글
XML Serialize, Deserialize (0) | 2013.07.31 |
---|---|
CreateUpdateQuery() (1) | 2008.04.28 |