using System.Data.SqlClient; using System.Data; using System.Diagnostics; using Cosmos.Common; /*-----------------------------------------------------------------------------------------------*/ // 설 명 : MSSQL DB 관련 처리 // 작 성 자 : // 변경 이력 : /*-----------------------------------------------------------------------------------------------*/ namespace Cosmos.BackgroundDown { public class DatabaseMssql { private SqlDB sqlDb = null; public bool Begin() { return sqlDb.DBBeginTransaction(); } public bool Commit() { return sqlDb.DBTransactionCommit(); } public bool Rollback() { return sqlDb.DBTransactionRollback(); } public void Close() { sqlDb.DBClose(); } /// /// SQL DataTable를 이용한 Select /// return -> 1:OK, -1:Connection 정보 에러, -2:SQL 에러, -3:기타 에러, 0:Select 결과 없음 /// /// /// /// public int DBSelect(string sQuery, out DataTable outDtReturn) { int iReturn = -9; DataTable dtReturn = null; string strCommand = sQuery; CommandType sqlCommandType = CommandType.Text; //System.Diagnostics.Debug.Print("SQL=" + sQuery); iReturn = sqlDb.DBDataTableSelect(strCommand, sqlCommandType, (SqlParameter[])null, out dtReturn); outDtReturn = dtReturn; return iReturn; } /// /// return -> 1:OK, -1:Connection 에러, -2:SQL 에러, -3:기타 에러, -4:적용된 Row 없음 /// /// /// public int DBExecuteNonQuery(string sQuery) { int iReturn = 0; CommandType sqlCommandType = CommandType.Text; iReturn = sqlDb.DBExecuteNonQuery(sQuery, sqlCommandType, (SqlParameter[])null); return iReturn; } /// /// return -> 1:OK, -1:Connection 에러, -2:SQL 에러, -3:기타 에러, -4:적용된 Row 없음 /// /// /// public int DBExecuteNonQuery(string[] sQuery) { int iReturn = 0; CommandType sqlCommandType = CommandType.Text; iReturn = sqlDb.DBExecuteNonQuery(sQuery, sqlCommandType, (SqlParameter[])null); return iReturn; } /// /// return -> 1:OK, -1:Connection 에러, -2:SQL 에러, -3:기타 에러, -4:적용된 Row 없음 /// /// /// public int DBExecuteNonQuery(string[] sQuery, bool bStandAlone) { int iReturn = 0; CommandType sqlCommandType = CommandType.Text; iReturn = sqlDb.DBExecuteNonQuery(sQuery, sqlCommandType, (SqlParameter[])null, bStandAlone); return iReturn; } /// /// MSSQL Database Conntction String /// /// /// /// /// public bool SetDBConnectionString(string pDataSource, string pInitialCatalog, string pUID, string pPassword) { bool bReturn = false; if(sqlDb != null) { if (sqlDb.IsDBOpen()) sqlDb.DBClose(); } sqlDb = new SqlDB(pDataSource, pInitialCatalog, pUID, pPassword); bReturn = sqlDb.IsDBOpen(); return bReturn; } } }