本文整理汇总了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;
}