Output Parameter always 0 when used with a dataadapter

T

Tommy

I have a stored procedure that has an output parameter defined as output and
it is definately being set in the proc. I even went as far as hard coding a
value in the bottom of the proc to be sure it had something other than 0. If
I run it in Sybase central (sybase's version of Query Analyzer) it always
comes back with a value. Here is my vb.net code.

The sp declaration is included in the code below so you can see what is
defined in the db.

I have no idea where else to go with this. Any assistance is appreciated.

Dim oCon As New iAnywhere.Data.AsaClient.AsaConnection(gcConnString)
Dim oDs As New DataSet
Dim oCmd As New iAnywhere.Data.AsaClient.AsaCommand("HHPriceData_Select")
oCmd.CommandType = CommandType.StoredProcedure
oCmd.Connection = oCon
'ALTER PROCEDURE "DBA"."HHPriceData_Select"
'(
' @lihhstcdfk INT,
' @lihhitemfk INT,
' @lcplcd CHAR(1),
' @lccompancd CHAR(15),
' @licount INT OUTPUT
' Setup the parameters
oCmd.Parameters.Add("@lihhstcdfk",
iAnywhere.Data.AsaClient.AsaDbType.Integer)
oCmd.Parameters.Add("@lihhitemfk",
iAnywhere.Data.AsaClient.AsaDbType.Integer)
oCmd.Parameters.Add("@lcplcd", iAnywhere.Data.AsaClient.AsaDbType.Char)
oCmd.Parameters.Add("@lccompancd", iAnywhere.Data.AsaClient.AsaDbType.Char)
oCmd.Parameters.Add("@licount", iAnywhere.Data.AsaClient.AsaDbType.Integer,
ParameterDirection.Output)
' Fill in the parameters
oCmd.Parameters("@lihhstcdfk").Value = iStoreCdFk
oCmd.Parameters("@lihhitemfk").Value = iItemFk
oCmd.Parameters("@lcplcd").Value = cLastPlcd
oCmd.Parameters("@lccompancd").Value = cCompanCD

Dim oDa As New iAnywhere.Data.AsaClient.AsaDataAdapter(oCmd)
oDa.Fill(oDs, "PriceData")

' -- SHOULD HAVE A VALUE HERE
Dim iCnt As Integer = oCmd.Parameters("@licount").Value
 
D

David Sceppa

Tommy,

You might want to check the value of the Direction property for this
parameter to make sure it's marked as an output parameter. I believe the
problem lies in how you're creating your output parameter:

.Add("@licount", AsaDbType.Integer, ParameterDirection.Output)

The first parameter in this method corresponds to Parameter.Name.
The second corresponds to
Parameter.<AppropriateProviderSpecificTypeProperty>
The third corresponds to Parameter.Size.

Double check with the documentation for your provider, but I believe
your best bets are to either use the parameter constructor that takes a
value for Direction, or to set the Direction property after your call to
Add.

I hope this information proves helpful.

David Sceppa
Microsoft
This posting is provided "AS IS" with no warranties,
and confers no rights. You assume all risk for your use.
© 2004 Microsoft Corporation. All rights reserved.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top