CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > starter_kits_and_source_projects.microsoft_application_blocks Tags:
Item Type: NewsGroup Date Entered: 12/16/2005 5:25:55 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 5 Views: 288 Favorited: 0 Favorite
6 Items, 1 Pages 1 |< << Go >> >|
lax4u
Asp.Net User
SqlHelper.ExecuteReader not populating ReturnValue12/16/2005 5:25:55 PM

0

I have StoredProc,which returns 0 if there is no error. My StoredProc look like this

CREATE PROCEDURE dbo.usp_GetData
   @intProviderID BIGINT
   
   
AS 
SET NOCOUNT ON

  DECLARE @ERROR    INT,
          @ROWCOUNT INT
 
 
 SELECT  

  FieldLenght,
  FieldPosition
 FROM dbo.FieldData WITH (READUNCOMMITTED)
 WHERE ProviderID = @intProviderID
 ORDER BY FieldPosition ASC
 
 
    SELECT
            @ERROR = @@ERROR, @ROWCOUNT = @@ROWCOUNT

  IF @ERROR<>0
            RETURN 1

  IF @ROWCOUNT=0
            RETURN 2     

RETURN 0
GO

This is wroking fine With SqlHelper.ExecuteDataset . I Get 0 in SQLParam[0].Value,Which i wanted.

SqlParameter[] SQLParam = new SqlParameter[2];   
SQLParam[0] = new SqlParameter("@ReturnValue", SqlDbType.Int);
SQLParam[0].Direction = ParameterDirection.ReturnValue; 
  
SQLParam[1] = new SqlParameter("@intProviderID", SqlDbType.BigInt);
SQLParam[1].Value = lProviderID;
    
dataset= SqlHelper.ExecuteDataset(ConnectionString, CommandType.StoredProcedure,
     "dbo.usp_GetData", SQLParam)

but if i use DataReader as

datareader= SqlHelper.ExecuteReader(ConnectionString, CommandType.StoredProcedure, "dbo.usp_GetData", SQLParam);

I dont get any value in SQLParam[0].Value . It says "undefined value"

any idea

AndrewSeven
Asp.Net User
Re: SqlHelper.ExecuteReader not populating ReturnValue12/16/2005 8:10:42 PM

0

I'm pulling from memory: I think you may need to read through all the rows of data before you will have access to the return value.
Ya_AA
Asp.Net User
Re: SqlHelper.ExecuteReader not populating ReturnValue12/17/2005 5:38:02 AM

0

Hello everyone.

 

I'e got a same problem with a bit different in coding.

I should receive some values which are sent by Sql stored procedures as output parameters. In fact, I've done this in Windows application by SqlHelper class and thought both of them (in win & web) have to be same. However after running Sqlhelper methods (executenonequery, executescaler) nothing can be returned into Web Form.

I couldn't understand why is wrong?

Following code snippet shows you the way that I used:

 

SqlParameter[] Params = new SqlParameter[2];

 

Params[0] = new SqlParameter("@RoleId", RoleId);

Params[1] = SqlParameter("@return, "");

 

Params[0] = SqlParameter.Direction.InputOutput;

Params[1] = SqlParameter.Direction.Output;

 

// Execute

SqlHelper.ExecuteNonQuery(Connection, CommandType.StoredProcedure, "ManageRoles", Params);

 

// Retrieve Value

int Role = Convert.ToInt32(Params[0]. Value.ToString());

string result = Params[1].Value.ToString();

 

 

 

Any suggestion to solve this problem would be truly appreciated.

- Thanks.

lax4u
Asp.Net User
Re: SqlHelper.ExecuteReader not populating ReturnValue12/19/2005 11:01:28 PM

0

ok now i got the value...if i close the reader i get the value in SQLParam[0]. and then .depend on that value i set my return status object. but when value is 0 which is SUCCESS i need the reader again in BO layer to iterate thru records.but now the reader is closed. so i cant use it..I know i can use Dataset but i'm not doing any update its will be just simple retrieve operation.any other solution
AndrewSeven
Asp.Net User
Re: SqlHelper.ExecuteReader not populating ReturnValue12/20/2005 11:16:06 PM

0

If you are passing the data between layers and the the data is fairly small, you should consider a dataset.

 

latticesoft
Asp.Net User
Re: SqlHelper.ExecuteReader not populating ReturnValue12/21/2005 3:26:31 PM

0

I prefer pass custom object between layers, I assum you follow three tier arachitecture:

UI-BL-DAL

So your DAL fetch data from database and return DataReader to BL, then BL build strong type custom object, close DataReader and connection, return custom object back to your UI.

Here is rule: fetch your data as late as possible and close connection as soon as possible. 


Li Xin
Get it Done! Simple is Best!
Lattice.DataMapper Persistence Framework for .NET
publicschoolportal.com
6 Items, 1 Pages 1 |< << Go >> >|


Free Download:


Web:
SqlHelper.ExecuteReader not populating ReturnValue - ASP.NET Forums SqlHelper.ExecuteReader not populating ReturnValue. Last post 12-21-2005 10:26 AM by latticesoft. 5 replies. Sort Posts: ...
CodeProject: Data Access Application Block .net 2.0 Get Return ... Sep 22, 2006 ... Note: I could not get the Return Value for the ExecuteDataReader .... Re: How about SqlHelper.ExecuteScalar to get return value ? member ...
CodeProject: Data Access Application Block .net 2.0 Get Return ... Sep 22, 2006 ... Using SqlHelper in .net 2.0 And getting Return Values and Output ... ToInt32( SqlHelper.ExecuteScalar(connString .... Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache) ..... Note: I could not get the Return Value for the ExecuteDataReader ...
.NET 247 Even when I specify the direction the SQLHelper.ExecuteReader method still treats the ... the right text but is not capturing the returned parameter value. ... Once the rowset is populated, the OUTPUT parameters appear next in the TDS stream. ... Add("Return Value: " & cmd.Parameters(0).ToString) ListBox1.Items. ...
CodeProject: Data Access Application Block .net 2.0 Get Return ... GetSpParameterSet to have my return value (The original code does not .... (or discover them & populate the cache) SqlParameter[] commandParameters = SqlHelperParameterCache. .... How about SqlHelper.ExecuteScalar to get return value ? ...

SqlHelper.ExecuteReader not populating ReturnValue - ng.asp-net ... SqlHelper.ExecuteReader not populating ReturnValue, > ROOT > NEWSGROUP > Asp.Net Forum ...
MS DAAB For Oracle - ExecuteScalar with Stored Procedure - ng.asp ... SqlHelper.ExecuteReader not populating ReturnValue - ng.asp-net ... Pull the parameters for this stored procedure from the parameter cache ...
ExecuteScalar Always Returns 0 - ng.asp-net-forum ... SqlHelper.ExecuteReader not populating ReturnValue - ng.asp-net ... I have StoredProc,which returns 0 if there is no error. ...
RSA Key container was not found - ERROR - ng.asp-net-forum.security Sometimes it does not get created by default. I hope this can help someone! Regards, ... sqlhelper.executereader not populating returnvalue ...
Close connection using ExecuteDataSet - ng.asp-net-forum ... SqlHelper.ExecuteReader not populating ReturnValue - ng.asp-net ... ExecuteDataset . I Get 0 in SQLParam[0].Value,Which i wanted. ... rule: ...






where can i get daab 3.0 (3.1)

application block

sybase with dal???

connection polling?

logging application block not writing to event log on windows 2000 sp4

enterprise library 3.0

question on sqlcommandbuilder.deriveparameters method

error trying to use daab in vb.net class

is option strict on or not?

system.configuration.configurationerrorsexception

enterprise library 3.1 (daab) and tableadapters

access 97 help!!!!

[entlib 2.0][daab]results of calling functions

timeout error using database blocks

need help in sql !!!!

smart client ffline application block

bug: sqlhelper.updatedataset

max connection pool reached

is anyone using this?

enterprise library on host - required permissions cannot be acquired. help?!

multiple active result sets with odp.net

enterprise library configuration

unable to open sln files in vs2002

dot matrix printing

can not understand ado error message

system.nullreferenceexception: object reference not set to an instance of an object. - exceptionpolicy.handleexception

can't create sqldatabase when using data access app block

annoying enterpriselibrary 2.0 bug

uip in web farm senario

very urgent: can anybody tell how to solve download error for manifest when using updater application block

   
  Privacy | Contact Us
All Times Are GMT