当前位置: 首页>>代码示例>>C#>>正文


C# SqlCommand.Clear方法代码示例

本文整理汇总了C#中System.Data.SqlClient.SqlCommand.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# SqlCommand.Clear方法的具体用法?C# SqlCommand.Clear怎么用?C# SqlCommand.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.SqlClient.SqlCommand的用法示例。


在下文中一共展示了SqlCommand.Clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Save

        /// <summary>
        /// you can supply your own SQL object and force the audit to go to that database.  Used by GT
        /// </summary>
        /// <param name="status"></param>
        /// <param name="CompletionMsg"></param>
        /// <param name="SQL"></param>
        /// <returns></returns>
        public long Save(CompletionStatus status, string CompletionMsg, SqlUtil SQL)
        {
            //save it - just in case of recovery
            mCompletionStatus = status;
            mCompletionMsg = CompletionMsg;

            string sql;

            SqlParameterCollection oParameters = new SqlCommand().Parameters;
            long ID = -1;

            oParameters.AddWithValue("@iDataType", DataUtils.DBNullIfNull(mDataType));
            oParameters.AddWithValue("@iDataID", DataUtils.DBNullIfNull(mDataID));
            oParameters.AddWithValue("@iCorrespondenceID", DataUtils.DBNullIfNull(mCorrespondenceID));
            oParameters.AddWithValue("@iEventID", DataUtils.DBNullIfNull(mEventID));
            oParameters.AddWithValue("@iEventDescription", DataUtils.DBNullIfNull(mEventDescription));
            oParameters.AddWithValue("@iCompletionMsg", DataUtils.DBNullIfNull(CompletionMsg));
            oParameters.AddWithValue("@iCompletionStatus", DataUtils.DBNullIfNull(status));
            if (mLogTime == DateTime.MinValue)
                mLogTime = DateTimeUtility.ServerDateNoRefresh();

            oParameters.AddWithValue("@iTime", mLogTime);

            sql = "set ansi_warnings off;INSERT INTO AuditHeader (DataType,DataID,CorrespondenceID,EventID,EventDescription,CompletionMsg,CompletionStatus,LogTime)"
                + " VALUES (@iDataType,@iDataID,@iCorrespondenceID,@iEventID,@iEventDescription,@iCompletionMsg,@iCompletionStatus,@iTime)";
            sql += "; select @@IDENTITY as ID";

            DataTable oTable;
            try {
                oTable = SQL.ExecuteSingleResultSetSQLQuery(sql, oParameters);
            } catch (Exception x) {
                if (mRecover && SqlRecover.SaveForRecovery(x, true, this, "auditheader"))
                    return 0;
                else
                    throw new Exception("sql error", x);
            }

            if (oTable.Rows.Count == 0)
                return -1;

            ID = DataUtils.LongZeroIfNull(oTable.Rows[0]["ID"]);
            if (ID < 1)
                return -1;

            if (mFieldChanges != null) {
                string o;
                string n;
                oParameters = new SqlCommand().Parameters;
                foreach (string field in mFieldChanges.UpdateList.Keys) {
                    mFieldChanges.GetAuditValue(field, out o, out n);

                    oParameters.AddWithValue("@iAuditID", ID);
                    oParameters.AddWithValue("@iField", DataUtils.DBNullIfNull(field));
                    oParameters.AddWithValue("@iOldVal", DataUtils.DBNullIfNull(o));
                    oParameters.AddWithValue("@iNewVal", DataUtils.DBNullIfNull(n));

                    sql = "set ansi_warnings off;INSERT INTO AuditDetail(AuditID,Field, OldValue,NewValue) " +
                         " VALUES (@iAuditID,@iField, @iOldVal,@iNewVal);";

                    SQL.ExecuteNoResultSetSQLQuery(sql, oParameters);
                    oParameters.Clear();
                }
            }

            return ID;
        }
开发者ID:adrichal,项目名称:SQLinqenlot,代码行数:73,代码来源:Audit.cs


注:本文中的System.Data.SqlClient.SqlCommand.Clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。