Hi,
I have a stored procedure that returns a single value. Example:
[...]
SELECT @RowCount = COUNT(*) FROM t WHERE [...]
RETURN @RowCount
I created a data set, table adapter, and adapter's method configured for the
stored proc and as returning a single value. The wizard created an adapter
method that calls SqlCommand.Exec uteScalar(). The problem is that
ExecuteScalar() always returns a null object. I have no problem executing
the stored procedure from outside of asp.net.
Could someone please let me give me some idea what could be wrong here?
Thanks,
Bogdan 3 4993
Have you set the SqlCommand.Comm andType to StoredProcedure ?
"bogdan" <bo****@company .comwrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
Hi,
I have a stored procedure that returns a single value. Example:
[...]
SELECT @RowCount = COUNT(*) FROM t WHERE [...]
RETURN @RowCount
I created a data set, table adapter, and adapter's method configured for
the stored proc and as returning a single value. The wizard created an
adapter method that calls SqlCommand.Exec uteScalar(). The problem is that
ExecuteScalar() always returns a null object. I have no problem executing
the stored procedure from outside of asp.net.
Could someone please let me give me some idea what could be wrong here?
Thanks,
Bogdan
I used TableAdapter Qeury Configuration Wizard and selected "Use existing
stored procedure".
"Waldy" <so*****@micros oft.comwrote in message
news:OL******** ******@TK2MSFTN GP06.phx.gbl...
Have you set the SqlCommand.Comm andType to StoredProcedure ?
"bogdan" <bo****@company .comwrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
>Hi,
I have a stored procedure that returns a single value. Example: [...] SELECT @RowCount = COUNT(*) FROM t WHERE [...] RETURN @RowCount
I created a data set, table adapter, and adapter's method configured for the stored proc and as returning a single value. The wizard created an adapter method that calls SqlCommand.Exec uteScalar(). The problem is that ExecuteScalar() always returns a null object. I have no problem executing the stored procedure from outside of asp.net.
Could someone please let me give me some idea what could be wrong here?
Thanks, Bogdan
executescaler returns the first column, of the first row, of the first
resultset. your stored proc does not return any rows, only a return value. to
get the return value, use ExecuteNonQuery with a returnvalue parameter
cmd.CommandText = "myproc";
cmd.CommandType = CommandType.Sto redProcedure;
SqlParameter param = new SqlParameter("@ returnValue",Sq lDbType.Int);
param.Direction = ParameterDirect ion.ReturnValue ;
cmd.Parameters. Add(param);
cmd.ExecuteNonQ uery();
int rows = (int) cmd.Parameters( "@returnValue") .Value;
-- bruce (sqlwork.com)
"bogdan" wrote:
Hi,
I have a stored procedure that returns a single value. Example:
[...]
SELECT @RowCount = COUNT(*) FROM t WHERE [...]
RETURN @RowCount
I created a data set, table adapter, and adapter's method configured for the
stored proc and as returning a single value. The wizard created an adapter
method that calls SqlCommand.Exec uteScalar(). The problem is that
ExecuteScalar() always returns a null object. I have no problem executing
the stored procedure from outside of asp.net.
Could someone please let me give me some idea what could be wrong here?
Thanks,
Bogdan This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: CJM |
last post by:
I frequently come across a small problem with my stored procedures; there
are plenty of way around it, but I'm figuring that maybe my approach is
subtly wrong.
My typical code to call an Stored Proc in ASP is as follows
sSQL = "Exec MySP 'xxx', 111, 'yyy', 222"
oConn.Execute sSQL
Usually the sSQL string is built up from several variables, e.g.
|
by: wackyphill |
last post by:
Using ADO.NET Or regular queries on SQL Server, is there a good way of
determining if a Stored Proc will be returning a result set or if it is
a non-query that does all I/O through parameters?
Thanks.
|
by: Andrew Baker |
last post by:
I have the following code that calles a stored proc in SQLServer. When the
output parameter @custref is null (System.DBNull) I cant seem to find a
test for this and I get an exception. I know I could coalesce the stored
proc, but I would like to know if the value is null.
How do you test for null in the returned parameter of a stored proc?
TIA
Andrew.
Dim retstr As String = ""
|
by: GaryDean |
last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much
in answers so I'm reposting some questions posted by some of the programmers
here in our organization that never got answered...
There are articles on the new TableAdapters where it says that a key new
advantage is that a single TableAdapter, which can have multiple queries,
can be used on multiple forms. Now that was in an article on using
TableAdapters with...
|
by: Siv |
last post by:
Hi,
I have a stored procedure that I want to execute and then wait in a loop
showing a timer whilst it completes and then carry on once I get
notification that it has completed. The main reason for this being to stop
the user thinking the application has frozen when in fact it is just waiting
for a long SP to complete. Another reason for doing it like this is that I
also have had a problem in the past where the SP takes longer than the...
| |
by: serge |
last post by:
/*
Subject: How to build a procedure that returns different
numbers of columns as a result based on a parameter.
You can copy/paste this whole post in SQL Query Analyzer
or Management Studio and run it once you've made sure
there is no harmful code.
Currently we have several stored procedures which final
result is a select with several joins that returns many
|
by: =?Utf-8?B?UmljaCBIdXRjaGlucw==?= |
last post by:
I'm not really sure how to ask this question because I'm still getting my
feet wet with data access and VB.NET, but here goes:
To start off with, I'm using VB 2005 Express to connect to an Access database.
I have a dataset in which a parameterized query returns the correct result
set in the forms of a tableadapter and a bindingnavigator. In other words, I
can perform my query and see that the tableadapter and bindingnavigator
contain...
|
by: =?Utf-8?B?Vmlua2k=?= |
last post by:
Hello Everyone,
I can successfully insert and update the oracle database by calling a
oracles stored proc from my .net code. This oracle stored proc is returning
some value. I cannot see that value in my .net code
Below is my .net code
OracleParameter mbrid = new OracleParameter("RET_MBRID", OracleType.Number);
mbrid.Direction = ParameterDirection.Output;
|
by: =?Utf-8?B?Vmlua2k=?= |
last post by:
Hello Everyone,
I can successfully insert and update the oracle database by calling a
oracles stored proc from my .net code. This oracle stored proc is returning
some value. I cannot see that value in my .net code
Below is my .net code
OracleParameter mbrid = new OracleParameter("RET_MBRID", OracleType.Number);
mbrid.Direction = ParameterDirection.Output;
|
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,...
|
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,...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |