[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

JeffK

5/13/2002 3:03:00 PM

I am having trouble returning codes to my Web Services
which uses ODBC.NET.

Sybase Adaptive Server 11 Stored procedure:
....
....
IF EXISTS ( SELECT myField
FROM myTable
WHERE some_key = @some_key)
BEGIN
return -2222
END
...
...

WebService Command:
int sqlRet2 = cmd1.ExecuteNonQuery();

sqlRet2 equals -1 even when the stored procedure condition
evaluates to TRUE. I need to see "-2222". Can someone
help?



1 Answer

J Wadie

5/31/2002 12:03:00 AM

0

Note the following from ODBC.NET documentation:
(OdbcCommand.ExecuteNonQuery Method)
Return Value:
For UPDATE, INSERT, and DELETE statements, the return
value is the number of rows affected by the command. For
all other types of statements, the return value is -1.

So, you should use ExecuteScalar instead of
ExecuteNonQuery, the correct code should be:

int sqlRet2 = (int)cmd1.ExecuteScalar();

>-----Original Message-----
>I am having trouble returning codes to my Web Services
>which uses ODBC.NET.
>
>Sybase Adaptive Server 11 Stored procedure:
>.....
>.....
> IF EXISTS ( SELECT myField
> FROM myTable
> WHERE some_key = @some_key)
> BEGIN
> return -2222
> END
>....
>....
>
>WebService Command:
> int sqlRet2 = cmd1.ExecuteNonQuery();
>
>sqlRet2 equals -1 even when the stored procedure
condition
>evaluates to TRUE. I need to see "-2222". Can someone
>help?
>
>
>
>.
>