我必须在数据库中记录Exception,我已经创建了pprocedure,配置了数据库跟踪侦听器,但我不明白,如何将参数发送到数据库中的存储过程,应该配置什么?< / p>
答案 0 :(得分:0)
/*
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Common;
using System.Data.Odbc;
using System.Data.OleDb;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
*/
public int DeleteSomething(System.Guid userUUID)
{
int rowsAffected = 0;
try
{
Database db = this.GetDatabase();
DbCommand dbc = db.GetStoredProcCommand("dbo.uspDeleteSomething");
dbc.CommandTimeout = 600;
db.AddInParameter(dbc, "@UserUUID", System.Data.DbType.Guid, userUUID );
rowsAffected = db.ExecuteNonQuery(dbc);
}
finally
{ }
return rowsAffected;
}
protected Microsoft.Practices.EnterpriseLibrary.Data.Database GetDatabase()
{
Database returnDb;
returnDb = Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.CreateDatabase();
return returnDb;
}