473,769 Members | 2,102 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 3502
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
1635
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
2119
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
2123
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
3199
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
4110
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
1543
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
1048
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
10208
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...
0
10038
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9987
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
8867
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, and deployment—without 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...
1
7404
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5294
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...
1
3952
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
3558
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.