473,405 Members | 2,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Help Required in SqlHelper.ExecuteNonQuery

RJN

Hi

I want to get the rerurn value from a stored procedure

My stored proc looks like this

create proc test
.....
if..
return 1
else
if ..
return 2
else
..return 0

I'm using the SqlHelper.ExecuteNonQuery and pass the procedure name,
connection and an array of parameters. How I do I get the return value
from this. If I create a parameter of Diretion ReturnValue and include
in the parameter array, I get an error that the parameters don't match.
WHat is the correct way of doing?

Regards

RJN

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #1
7 7521
Hi,

Use ExecuteScalar instead.

http://msdn.microsoft.com/library/de...calartopic.asp

Ken
-------------------------
"RJN" <rj*@yahoo.com> wrote in message
news:u8**************@TK2MSFTNGP10.phx.gbl...

Hi

I want to get the rerurn value from a stored procedure

My stored proc looks like this

create proc test
.....
if..
return 1
else
if ..
return 2
else
..return 0

I'm using the SqlHelper.ExecuteNonQuery and pass the procedure name,
connection and an array of parameters. How I do I get the return value
from this. If I create a parameter of Diretion ReturnValue and include
in the parameter array, I get an error that the parameters don't match.
WHat is the correct way of doing?

Regards

RJN

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #2
Use executeScalar to return a ret val. ExecuteNonQuery would be for
something like "set transaction isolation level read uncommitted" or
similar.

hth
Eric
RJN wrote:
Hi

I want to get the rerurn value from a stored procedure

My stored proc looks like this

create proc test
....
if..
return 1
else
if ..
return 2
else
..return 0

I'm using the SqlHelper.ExecuteNonQuery and pass the procedure name,
connection and an array of parameters. How I do I get the return value
from this. If I create a parameter of Diretion ReturnValue and include
in the parameter array, I get an error that the parameters don't
match. WHat is the correct way of doing?

Regards

RJN

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 21 '05 #3

"Eric Sabine" <mopar41@mail_after_hot_not_before.com> wrote in message
news:e3**************@TK2MSFTNGP15.phx.gbl...
Use executeScalar to return a ret val. ExecuteNonQuery would be for
something like "set transaction isolation level read uncommitted" or
similar.


....or something less exotic like INSERT, UPDATE, or DELETE.
Nov 21 '05 #4
Jeff Johnson wrote:
"Eric Sabine" <mopar41@mail_after_hot_not_before.com> wrote in message
news:e3**************@TK2MSFTNGP15.phx.gbl...

Use executeScalar to return a ret val. ExecuteNonQuery would be for
something like "set transaction isolation level read uncommitted" or
similar.

...or something less exotic like INSERT, UPDATE, or DELETE.


LOL
Nov 21 '05 #5
RJN

Forgot to mention that I'm having update statements in the stored proc
so i can't use ExecuteScalar
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #6
True, but DML from the front-end is bad practice. Stored procedures should
be the only means of DML.
Jeff Johnson wrote:
"Eric Sabine" <mopar41@mail_after_hot_not_before.com> wrote in message
news:e3**************@TK2MSFTNGP15.phx.gbl...
Use executeScalar to return a ret val. ExecuteNonQuery would be for
something like "set transaction isolation level read uncommitted" or
similar.


...or something less exotic like INSERT, UPDATE, or DELETE.

Nov 21 '05 #7
Hi,

I guess an output parameter is your only option.

http://support.microsoft.com/default...b;en-us;308049

Ken
---------------
"RJN" <rj*@yahoo.com> wrote in message
news:Oo**************@TK2MSFTNGP10.phx.gbl...

Forgot to mention that I'm having update statements in the stored proc
so i can't use ExecuteScalar
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Brian | last post by:
I am trying to pass a null value into a stored procedure so that it can save the data. I am using Microsoft's SQLHelper dll to do this. My example code is below. How do I pass in a null value...
1
by: Alpha | last post by:
I have a Window based application that shows up still running in the task manager when I close it. It reaches the "this.close" statement and then it stops at the "}" at the section of the...
7
by: Neven Klofutar | last post by:
Hi, I have a problem with SqlHelper.ExecuteScalar ... When I try to execute SqlHelper.ExecuteScalar I get this message: "System.InvalidCastException: Object must implement IConvertible.". ...
3
by: Tim::.. | last post by:
Can someone please help.... I'm having major issues with a user control I'm tring to create! I an trying to execute a sub called UploadData() from a user control which I managed to do but for...
3
by: Shapper | last post by:
Hello, I have created 3 functions to insert, update and delete an Access database record. The Insert and the Delete code are working fine. The update is not. I checked and my database has all...
3
by: Adriano | last post by:
Hello, when I try to print something, either DataGrid or from Crystal Report viever the folowing error message appears and cancels printing: Object reference not set to an instance of an...
0
by: Manuel | last post by:
I'm using the SQLHelper class to do an insert and get the identity field this way: -------------- Dim sql As String = "INSERT INTO () VALUES ('MyMessage');SELECT SCOPE_IDENTITY()" Dim ds As...
4
by: John F | last post by:
Hello All, What is the consensus on using sqlhelper or not using sqlhelper when calling stored procedures? We're trying to go with a standard for our projects and personally I prefer not...
1
by: =?Utf-8?B?Ymlj?= | last post by:
Hi, Calling my method below how does my page caller display the exception since the return type is int? int ret = 0; string spname = "sp_UpdateAd"; try { //Retrieve the parameters from the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.