How do you execute a stored procedure in subsonic 3.0 that returns a value? For example many of my stored procedures return @@identity, and I can't figure out how to access that value without re querying the table. Again, not an output parameter, but a return value.
views:
803answers:
6
+5
A:
StoredProcedure sproc = db.FancySchmancySproc();
sproc.Execute();
int output = (int)sproc.Output; // returns type 'object' so you'll need to cast
John Sheehan
2009-07-28 19:17:09
A:
That is what I thought, but sproc.output is always null. I wonder if there's a bug in the latest version 3.0.0.3
mafudge
2009-07-29 13:43:57
+1
A:
StoredProcedure sp = SPs.TestProcedure(0);
sp.Command.AddReturnParameter();
object retValue = sp.Command.Parameters.Find(delegate(QueryParameter p)
{
return p.Mode == ParameterDirection.ReturnValue;
}).ParameterValue;
if (retValue!=null)
{
// cast the value to the type expected
int rc = (int) retValue;
}
Pedro Tiago Pereira
2009-08-05 02:04:22
+1
A:
This works for me:
StoredProcedure sproc = db.FancySchmancySproc();
sproc.ExecuteScalar<int>();
rball
2010-01-05 05:20:55
A:
sproc.ExecuteDataSet() returns an error
The SelectCommand property has not been initialized before calling 'Fill'.
please help
aous
2010-06-23 17:03:13