예제 #1
0
 public bool _ExecuteDestroy(DBOperator dbOp)
 {
     try
     {
         mDataAdapter.DeleteCommand = dbOp.ToSqlCommand(mConnection);
         mDataAdapter.DeleteCommand.ExecuteNonQuery();
     }
     catch (System.Exception e)
     {
         Log.Log.Common.Print(e.ToString());
         Log.Log.Common.Print(dbOp.SqlCode);
         return(false);
     }
     return(true);
 }
예제 #2
0
        public void _ExecuteUpdate(DBOperator dbOp)
        {
            if (dbOp == null)
            {
                return;
            }
            try
            {
                mDataAdapter.UpdateCommand = dbOp.ToSqlCommand(mConnection);

                mDataAdapter.UpdateCommand.ExecuteNonQuery();
                mDataAdapter.UpdateCommand = null;
            }
            catch (System.Exception e)
            {
                Log.Log.Common.Print(e.ToString());
                Log.Log.Common.Print(dbOp.SqlCode);
            }
        }
예제 #3
0
 public System.Data.DataTable _ExecuteSql(string sql, string tabName)
 {
     System.Data.DataSet result = new System.Data.DataSet();
     try
     {
         DBOperator dbOp = new DBOperator();
         dbOp.ExeType = SqlExeType.Select;
         dbOp.SqlCode = sql;
         mDataAdapter.SelectCommand = dbOp.ToSqlCommand(mConnection);
         mDataAdapter.Fill(result, tabName);
         mDataAdapter.SelectCommand = null;
     }
     catch (System.Exception e)
     {
         Log.Log.Common.Print(e.ToString());
         Log.Log.Common.Print(e.StackTrace.ToString());
         return(null);
     }
     return(result.Tables[0]);
 }
예제 #4
0
        public System.Data.DataTable _ExecuteSelect(DBOperator dbOp, string tabName)
        {
            System.Data.DataSet result = new System.Data.DataSet();
            try
            {
                mDataAdapter.SelectCommand = dbOp.ToSqlCommand(mConnection);
                //System.Data.SqlClient.SqlCommandBuilder myCB = new System.Data.SqlClient.SqlCommandBuilder(mDataAdapter);
                //int iRet = mDataAdapter.SelectCommand.ExecuteReader()

                mDataAdapter.Fill(result, tabName);
                mDataAdapter.SelectCommand = null;
            }
            catch (System.Exception e)
            {
                Log.Log.Common.Print(e.ToString());
                Log.Log.Common.Print(e.StackTrace.ToString());
                return(null);
            }
            return(result.Tables[0]);
        }
예제 #5
0
        public bool _ExecuteInsert(DBOperator dbOp)
        {
            try
            {
                mDataAdapter.InsertCommand = dbOp.ToSqlCommand(mConnection);
                mDataAdapter.InsertCommand.ExecuteNonQuery();
                mDataAdapter.InsertCommand = null;
            }
            catch (System.Exception e)
            {
                if (e.ToString().Contains("for key")) //包含主键或唯一键值
                {
                    return(false);
                }

                Log.Log.Common.Print(e.ToString());
                Log.Log.Common.Print(dbOp.SqlCode);
                return(false);
            }
            return(true);
        }