473,746 Members | 2,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Exec uteScalar(AppVa rs.strConn, _
"gpUpdateMember ", _
Convert.ToInt32 (lblMember_id.T ext), _
-snip-

-Max
Nov 18 '05 #1
6 3501
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****@notvali d.com> wrote in message
news:uA******** ******@tk2msftn gp13.phx.gbl...
Anyone know why I'm always getting 0 returned? My stored procedure
returns -1.

Dim iErrorCode As Int32
iErrorCode = Convert.ToInt32 (SqlHelper.Exec uteScalar(AppVa rs.strConn, _
"gpUpdateMember ", _
Convert.ToInt32 (lblMember_id.T ext), _
-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.nosp am> wrote in message
news:uT******** ******@tk2msftn gp13.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****@notvali d.com> wrote in message
news:uA******** ******@tk2msftn gp13.phx.gbl...
Anyone know why I'm always getting 0 returned? My stored procedure
returns -1.

Dim iErrorCode As Int32
iErrorCode = Convert.ToInt32 (SqlHelper.Exec uteScalar(AppVa rs.strConn, _
"gpUpdateMember ", _
Convert.ToInt32 (lblMember_id.T ext), _
-snip-

-Max


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

cmd.Parameters. Add("RETURN_VAL UE", SqlDbType.Int). Direction =
ParameterDirect ion.ReturnValue
....
Dim retval as integer = CInt(cmd.Parame ters("RETURN_VA LUE").Value)

HTH,
Greg
"Max" <no****@notvali d.com> wrote in message
news:eh******** ******@TK2MSFTN GP09.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.nosp am> wrote in message
news:uT******** ******@tk2msftn gp13.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****@notvali d.com> wrote in message
news:uA******** ******@tk2msftn gp13.phx.gbl...
Anyone know why I'm always getting 0 returned? My stored procedure
returns -1.

Dim iErrorCode As Int32
iErrorCode = Convert.ToInt32 (SqlHelper.Exec uteScalar(AppVa rs.strConn, _
"gpUpdateMember ", _
Convert.ToInt32 (lblMember_id.T ext), _
-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@DON T_SPAM_ME_hotma il.com> wrote in message
news:eb******** ******@TK2MSFTN GP15.phx.gbl...
To get a Return value you have to use a parameter...

cmd.Parameters. Add("RETURN_VAL UE", SqlDbType.Int). Direction =
ParameterDirect ion.ReturnValue
...
Dim retval as integer = CInt(cmd.Parame ters("RETURN_VA LUE").Value)

HTH,
Greg
"Max" <no****@notvali d.com> wrote in message
news:eh******** ******@TK2MSFTN GP09.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.nosp am> wrote in message
news:uT******** ******@tk2msftn gp13.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****@notvali d.com> wrote in message
news:uA******** ******@tk2msftn gp13.phx.gbl...
Anyone know why I'm always getting 0 returned? My stored procedure
returns -1.

Dim iErrorCode As Int32
iErrorCode = Convert.ToInt32 (SqlHelper.Exec uteScalar(AppVa rs.strConn, _
"gpUpdateMember ", _
Convert.ToInt32 (lblMember_id.T ext), _
-snip-

-Max



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

SELECT @errorcode

Greg
"Max" <no****@notvali d.com> wrote in message
news:ei******** *******@TK2MSFT NGP11.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@DON T_SPAM_ME_hotma il.com> wrote in message
news:eb******** ******@TK2MSFTN GP15.phx.gbl...
To get a Return value you have to use a parameter...

cmd.Parameters. Add("RETURN_VAL UE", SqlDbType.Int). Direction =
ParameterDirect ion.ReturnValue
...
Dim retval as integer = CInt(cmd.Parame ters("RETURN_VA LUE").Value)

HTH,
Greg
"Max" <no****@notvali d.com> wrote in message
news:eh******** ******@TK2MSFTN GP09.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.nosp am> wrote in message
news:uT******** ******@tk2msftn gp13.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****@notvali d.com> wrote in message
news:uA******** ******@tk2msftn gp13.phx.gbl...
> Anyone know why I'm always getting 0 returned? My stored procedure
> returns -1.
>
> Dim iErrorCode As Int32
> iErrorCode = Convert.ToInt32 (SqlHelper.Exec uteScalar(AppVa rs.strConn,
> _
> "gpUpdateMember ", _
> Convert.ToInt32 (lblMember_id.T ext), _
> -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@DON T_SPAM_ME_hotma il.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
You almost got it, just drop the RETURN part

SELECT @errorcode

Greg
"Max" <no****@notvali d.com> wrote in message
news:ei******** *******@TK2MSFT NGP11.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
1633
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 = m_PSiebelDocument.CreateInstance(MSXML2::CLSID_DOMDocument); if(SUCCEEDED(hr)) {
3
2118
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 page from? (I.e. 3.1415 not 3,1415) Thanks in advance, Jeremy
2
2119
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 = $_POST;
1
3197
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 follows: The code below is for the first page:session_start is in line 3 <link href="css/jobSheet.css" rel="stylesheet" type="text/css" /> session_start();
2
9486
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 ,But Report Viewer Toolbar is not working Ex Print Command Button and if I try to move to next page I am getting error “The source of the report definition has not been specified “ “
2
1728
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; Autopostback = false; EnableViewState = true;
2
4109
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 something else that will give me the complete output returned as a string that I can convert to a GD lib image resource so I can verify the operation worked before sending the Content-type header for the image. This works:...
6
1540
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 --------- Purchased---100 qty & Sales-----50 qty 1.3----------Purcahsed---300 qty & sales-----100 qty 1.2--------- Purcahsed--000 qty & sales-----20 qty
0
1044
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: http://www.gnu.org/software/libc/manual/html_mono/libc.html#Standard-Streams Function: FILE * freopen (const char *filename, const char *opentype, FILE *stream)
0
8974
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8800
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9508
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9285
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8229
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 projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4586
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4836
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3292
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2765
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.