如果您使用的是EnterpriseLibrary(和它看起來像你)試試這個:
Microsoft.Practices.EnterpriseLibrary.Data.Database db = Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.CreateDatabase("ConnectionString");
System.Data.Common.DbCommand cmd = db.GetStoredProcCommand("StoredProcedureName");
cmd.CommandTimeout = 600;
db.AddInParameter(cmd, "ParameterName", DbType.String, "Value");
// Added to handle paramValues array conversion
foreach (System.Data.SqlClient.SqlParameter param in parameterValues)
{
db.AddInParameter(cmd, param.ParameterName, param.SqlDbType, param.Value);
}
return cmd.ExecuteScalar();
編輯處理直接基於評論paramValues陣列。我還包括你的ConnectionString值:
Microsoft.Practices.EnterpriseLibrary.Data.Database db = Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.CreateDatabase(connectionManager.SqlConnection.ConnectionString);
System.Data.Common.DbCommand cmd = db.GetStoredProcCommand("StoredProcedureName", parameterValues);
cmd.CommandTimeout = 600;
return cmd.ExecuteScalar();
OK,downvoting我的問題僅僅是粗魯的。我的問題是明確的,並且(希望)有一個答案。 – BoltBait 2009-07-10 21:06:05