locked
ExecuteDataset and Output parameters in DAAB RRS feed

  • Question

  • User-491301336 posted

    Hi all...

    I've run a couple of searches on this issue, but have yet to find a concrete answer. My apologies if I'm re-hashing old ground.

    I'm using the new Enterprise Library DAAB and attempting to return a dataset AND obtain a value through an output parameter. This could be achieved in the old version of the DAAB, but I can't figure out why it's going wrong with the Enterprise Library version. Can this still be accomplished?

    The best I have been able to do is get the output parameter to return DBNull. I have confirmed that the stored procedure is actually returning a value. My simplified code snippet is below. Many thanks to anyone who is able to steer me in the right direction.

    public ArrayList getPagedFileType(int pageIndex, int pageSize)
    {
       ArrayList fieldTypes =
    new ArrayList();
       Database db = DatabaseFactory.CreateDatabase();
       SqlCommandWrapper comm = (SqlCommandWrapper) db.GetStoredProcCommandWrapper("usp_SelectPagedFieldTypeAll");
       comm.AddInParameter("pageIndex",DbType.Int32,pageIndex);
       comm.AddInParameter("pageSize",DbType.Int32,pageSize);
       comm.AddOutParameter("TotalRecords",DbType.Int32,4);

       SqlDataReader dr = (SqlDataReader)db.ExecuteReader(comm);
    //This is the line that fails - i never contains a value
       int i = (int)((SqlParameter)comm.Command.Parameters["@TotalRecords"]).Value;
       fieldTypes.AddRange(ObjectHelper.FillCollection(dr,
    typeof(FieldTypeObj)));
       return fieldTypes;
    }

    Thanks,
    Jarcil 

    Thursday, June 30, 2005 9:51 PM

All replies

  • User-491301336 posted
    Does the silence mean I've asked a stupid question, or is it just a case of noone else knowing the answer?
    Thursday, July 14, 2005 9:20 PM