472,364 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

always getting a 0 returned using ExecuteScalar (ms datablocks)

Max
Anyone know why I'm always getting 0 returned? My stored procedure
returns -1.

Dim iErrorCode As Int32
iErrorCode = Convert.ToInt32(SqlHelper.ExecuteScalar(AppVars.st rConn, _
"gpUpdateMember", _
Convert.ToInt32(lblMember_id.Text), _
-snip-

-Max
Nov 18 '05 #1
6 3419
ExecuteScalar: Executes the query, and returns the first column of the
first row in the result set returned by the query. Extra columns or rows are
ignored.

What were you expecting back?
"Max" <no****@notvalid.com> wrote in message
news:uA**************@tk2msftngp13.phx.gbl...
Anyone know why I'm always getting 0 returned? My stored procedure
returns -1.

Dim iErrorCode As Int32
iErrorCode = Convert.ToInt32(SqlHelper.ExecuteScalar(AppVars.st rConn, _
"gpUpdateMember", _
Convert.ToInt32(lblMember_id.Text), _
-snip-

-Max

Nov 18 '05 #2
Max
In my stored proc I have return @errorcode or return -1

I thought ExecuteScalar was for getting a single value...

"Scott M." <s-***@nospam.nospam> wrote in message
news:uT**************@tk2msftngp13.phx.gbl...
ExecuteScalar: Executes the query, and returns the first column of the
first row in the result set returned by the query. Extra columns or rows
are ignored.

What were you expecting back?
"Max" <no****@notvalid.com> wrote in message
news:uA**************@tk2msftngp13.phx.gbl...
Anyone know why I'm always getting 0 returned? My stored procedure
returns -1.

Dim iErrorCode As Int32
iErrorCode = Convert.ToInt32(SqlHelper.ExecuteScalar(AppVars.st rConn, _
"gpUpdateMember", _
Convert.ToInt32(lblMember_id.Text), _
-snip-

-Max


Nov 18 '05 #3
To get a Return value you have to use a parameter...

cmd.Parameters.Add("RETURN_VALUE", SqlDbType.Int).Direction =
ParameterDirection.ReturnValue
....
Dim retval as integer = CInt(cmd.Parameters("RETURN_VALUE").Value)

HTH,
Greg
"Max" <no****@notvalid.com> wrote in message
news:eh**************@TK2MSFTNGP09.phx.gbl...
In my stored proc I have return @errorcode or return -1

I thought ExecuteScalar was for getting a single value...

"Scott M." <s-***@nospam.nospam> wrote in message
news:uT**************@tk2msftngp13.phx.gbl...
ExecuteScalar: Executes the query, and returns the first column of the
first row in the result set returned by the query. Extra columns or rows
are ignored.

What were you expecting back?
"Max" <no****@notvalid.com> wrote in message
news:uA**************@tk2msftngp13.phx.gbl...
Anyone know why I'm always getting 0 returned? My stored procedure
returns -1.

Dim iErrorCode As Int32
iErrorCode = Convert.ToInt32(SqlHelper.ExecuteScalar(AppVars.st rConn, _
"gpUpdateMember", _
Convert.ToInt32(lblMember_id.Text), _
-snip-

-Max



Nov 18 '05 #4
Max
Thanks I know that works, but principally speaking I swore I could return a
value with ExecuteScalar. I think it's my return statement in the stored
procedure...

something like...
RETURN SELECT @errorcode
or..
RETURN SELECT myvar = @errorcode

Something that returns a recordset, but it doesn't...

Thanks for your guys help!

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:eb**************@TK2MSFTNGP15.phx.gbl...
To get a Return value you have to use a parameter...

cmd.Parameters.Add("RETURN_VALUE", SqlDbType.Int).Direction =
ParameterDirection.ReturnValue
...
Dim retval as integer = CInt(cmd.Parameters("RETURN_VALUE").Value)

HTH,
Greg
"Max" <no****@notvalid.com> wrote in message
news:eh**************@TK2MSFTNGP09.phx.gbl...
In my stored proc I have return @errorcode or return -1

I thought ExecuteScalar was for getting a single value...

"Scott M." <s-***@nospam.nospam> wrote in message
news:uT**************@tk2msftngp13.phx.gbl...
ExecuteScalar: Executes the query, and returns the first column of the
first row in the result set returned by the query. Extra columns or rows
are ignored.

What were you expecting back?
"Max" <no****@notvalid.com> wrote in message
news:uA**************@tk2msftngp13.phx.gbl...
Anyone know why I'm always getting 0 returned? My stored procedure
returns -1.

Dim iErrorCode As Int32
iErrorCode = Convert.ToInt32(SqlHelper.ExecuteScalar(AppVars.st rConn, _
"gpUpdateMember", _
Convert.ToInt32(lblMember_id.Text), _
-snip-

-Max



Nov 18 '05 #5
You almost got it, just drop the RETURN part

SELECT @errorcode

Greg
"Max" <no****@notvalid.com> wrote in message
news:ei***************@TK2MSFTNGP11.phx.gbl...
Thanks I know that works, but principally speaking I swore I could return
a value with ExecuteScalar. I think it's my return statement in the stored
procedure...

something like...
RETURN SELECT @errorcode
or..
RETURN SELECT myvar = @errorcode

Something that returns a recordset, but it doesn't...

Thanks for your guys help!

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:eb**************@TK2MSFTNGP15.phx.gbl...
To get a Return value you have to use a parameter...

cmd.Parameters.Add("RETURN_VALUE", SqlDbType.Int).Direction =
ParameterDirection.ReturnValue
...
Dim retval as integer = CInt(cmd.Parameters("RETURN_VALUE").Value)

HTH,
Greg
"Max" <no****@notvalid.com> wrote in message
news:eh**************@TK2MSFTNGP09.phx.gbl...
In my stored proc I have return @errorcode or return -1

I thought ExecuteScalar was for getting a single value...

"Scott M." <s-***@nospam.nospam> wrote in message
news:uT**************@tk2msftngp13.phx.gbl...
ExecuteScalar: Executes the query, and returns the first column of the
first row in the result set returned by the query. Extra columns or
rows are ignored.

What were you expecting back?
"Max" <no****@notvalid.com> wrote in message
news:uA**************@tk2msftngp13.phx.gbl...
> Anyone know why I'm always getting 0 returned? My stored procedure
> returns -1.
>
> Dim iErrorCode As Int32
> iErrorCode = Convert.ToInt32(SqlHelper.ExecuteScalar(AppVars.st rConn,
> _
> "gpUpdateMember", _
> Convert.ToInt32(lblMember_id.Text), _
> -snip-
>
> -Max
>



Nov 18 '05 #6
Max
I think you're right! lol! This tells me I need to get a book on tsql
instead of relying on samples and quick start guides.

Thanks!

-Max
"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
You almost got it, just drop the RETURN part

SELECT @errorcode

Greg
"Max" <no****@notvalid.com> wrote in message
news:ei***************@TK2MSFTNGP11.phx.gbl...
Thanks I know that works, but principally speaking I swore I could return
a value with ExecuteScalar. I think it's my return statement in the
stored procedure...

something like...
RETURN SELECT @errorcode
or..
RETURN SELECT myvar = @errorcode

Something that returns a recordset, but it doesn't...

Thanks for your guys help!

Nov 18 '05 #7

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

Similar topics

0
by: Punit | last post by:
Hi, Could someone please suggest where I am going wrong... Iam using MSXML 3.0 and VC++ but i end up getting blank response XML try { hr =...
3
by: JDC | last post by:
Hi all, Is there a recommended way (i.e. not a bodge) to get a GridView to always display decimal numbers using a dot as the decimal separator, regardless of the locale the user is viewing the...
2
by: pm1ccc | last post by:
Hi, I have written following code and not getting back values in the same form ( i have used phpself) <?php $Fname = $_POST; $Lname = $_POST; $gender = $_POST; $food = $_POST; $quote =...
1
by: simbarashe | last post by:
Hie could someone please help me with getting and using the current page url. I have a function that gets the url, I want to use it with header(location : XXX) but it wont work. The code is as...
2
by: =?Utf-8?B?R3lhbmVuZHJh?= | last post by:
I am using Ajax control(Update Panel) in my web page(ASP.Net 2.0) and putting Report Viewer(Sql Server Reporting Services 2005) Control in it. When I am displaying any report it is coming...
2
by: programmerboy | last post by:
This questions is pretty easy, but let me ask since I wasn't able to figure it out. why I am always getting the first value from DropDownList when I have ddlStates.SelectedItem.Value; ...
2
by: Chuck Anderson | last post by:
I am trying to use ImageMagick to create thumbnails on the fly - without having to save the image to a file. I have gotten it to work by using passthru($cmd, $retval), but I want to use...
6
manoj9849967222
by: manoj9849967222 | last post by:
Hi All I have a great problem. I have three tables one is "SALES" other one is "Purchase" & "Productid" Now i want to get the closing stock out of it. Say productid is 1.2 ---------...
0
by: Christian Heimes | last post by:
Grant Edwards wrote: It's dangerous to mix streams and descriptors. Traditionally freopen() is used to redirect a standard stream to a file: ...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...

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.