using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data.SqlClient; using System.Data; using System.Configuration; /// /// autoExecSQL 的摘要描述 /// public class autoExecSQL { private string _strSQL = ""; private int _intEffectNum = 0; private SqlConnection _objConn = new SqlConnection(ConfigurationManager.ConnectionStrings["DBConnectionString"].ConnectionString); private SqlCommand _objCmd; public autoExecSQL(string strSQL) { // // TODO: 在這裡新增建構函式邏輯 // _strSQL = strSQL; try { _objConn.Open(); _objCmd = new SqlCommand(_strSQL, _objConn); _intEffectNum = _objCmd.ExecuteNonQuery(); _objConn.Close(); _objConn.Dispose(); } catch (Exception ex) { _objConn.Close(); _objConn.Dispose(); throw new Exception("Exec SQL 發生錯誤! " + ex.Message); } } public string strSQL { get { return this._strSQL; } } public int effectDataCount { get { return _intEffectNum; } } }