|
The database operation classes used by my program all use SqlHelper
My stored procedure stores an output parameter that returns the number of rows in the query, but after executing ExecuteReader, the value is null. I put
The Reader object is closed before it can be retrieved and served. What do I do with output after I close it? How do I get the output value before the Reader object is closed? Is it a bug or does it let you fetch it?
---------------------------------- The stored procedure is as follows ------------- --------------
---------------------------------- Tested stored procedures no problem ---------- ---------
CREATE PROCEDURE [dbo]. [SelectInitCar]
@ShowType bit, @Rowss smallint output
AS
If @ShowType = 1
Begin
select Car.CarID, Car.CarName, Car.CarSim, Car.LogTime,
OrienSet.Stake, OrienSet.MapStake, OrienSet.LonOrOffset, OrienSet.LatOrOffset
From Car JOIN OrienSet ON Car.CarID = OrienSet.CarID
select @Rowss = @@ rowcount
End
Else
Begin
select Car.CarID, Car.CarName, Car.CarSim, Car.LogTime,
OrienSet.Stake, OrienSet.MapStake, OrienSet.LonOrOffset, OrienSet.LatOrOffset,
CarGroup.GroupID, CarGroup.GroupName
From CarGroup
LEFT JOIN Car ON CarGroup.GroupID = Car.GroupID
JOIN OrienSet ON Car.CarID = OrienSet.CarID
select @Rowss = @@ rowcount
End
-------------------------------------------------- -------------------------------------------------- ----------------------------------------------
----------------------code show as below-------------------------- -------------------------------------------------- --------------------------------------
SqlParameter [] sps = new SqlParameter [2];
sps [0] = new SqlParameter ("@ ShowType", SqlDbType.Bit);
sps [0] .Direction = ParameterDirection.Input;
sps [1] = new SqlParameter ("@ Rowss", SqlDbType.SmallInt);
sps [1] .Direction = ParameterDirection.Output;
SqlDataReader dr = (SqlDataReader) Communal.Ahelper.ExecuteReader (Communal.SqlStr, CommandType.StoredProcedure, "SelectInitCar", sps);
//dr.Close ();
string xxxx = Convert.ToString (sps [1] .Value);
-------------------------------------------------- -----------------------
Who knows sqlhelper better, tell me to change there too! !! Please enlighten me why the value is not working when dr is on? How to solve it, thank you |
|