I am going to use ADO.NET to call a sqlserver stored procedure with 1
parameter
The stored procedured will return a record set with one row data.
I have already get connection to the server and added the parameter,
but I cannot get the result by sqldatareader =
sqlcommand.exec utereader.
I ensure that there is one row return.
Besides, I would like to use the same sqlcommand to run a number of
query in difference function by declaire the variable in global, does
it good idea or I should declaire it in each function?
If it is good to do that, How can I close the sqlcommand and use the
same object in other function just like old ADODB rs.close?
Thank you. 1 1212
Hi
First, try using a DataAdapter instead of a datareader.
Use it to fill a new dataset.
You can use the same command object to create a data adapter.
The data adapter will open and close the connection for you so you
don't need to do this.
If you need to reuse the command, you can probably use the "singleton"
pattern to define a class that can only be instantiated once and
reused. Google for singleton
In your little class, you can have a method that accepts the parameter
and returns a dataset. That method creates your data adapter and fills
the new dataset. As I said above, data adapters will open and close the
connection for you so you don't need to worry about it.
Cylix wrote:
I am going to use ADO.NET to call a sqlserver stored procedure with 1
parameter
The stored procedured will return a record set with one row data.
I have already get connection to the server and added the parameter,
but I cannot get the result by sqldatareader =
sqlcommand.exec utereader.
I ensure that there is one row return.
Besides, I would like to use the same sqlcommand to run a number of
query in difference function by declaire the variable in global, does
it good idea or I should declaire it in each function?
If it is good to do that, How can I close the sqlcommand and use the
same object in other function just like old ADODB rs.close?
Thank you.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: M Wells |
last post by:
Hi All,
I'm trying to track down a mysterious problem we're experiencing in
which updates and inserts to tables in our mssql2k server appear to be
'disappearing.'
To explain our situation:
We have a web page (written in ASP, if that's relevant) on which we
accept enrollment information.
|
by: serge |
last post by:
My project is to automate testing of Stored Procedures
of type SELECT (at least for now).
I want to create a table where each stored procedure's
input parameter values are entered and in another table
the expected result value(s) are entered when executed
against a sample database containing manually entered
and verified data.
My current problem is that the stored procedures' input
|
by: Raquel |
last post by:
This is a very simple DB2 SQLJ stored procedure. The problem is that it
seems to run fine but returns NOTHING. I mean..as if nothing has
happened..not resultset is returned. I am passing value 'D11' to :workdept
and I have checked in the table that 6 rows should have returned. Any
ideas why no resultset is being returned.
import java.sql.*;
import sqlj.runtime.*;
import sqlj.runtime.ref.*;
import java.io.*; // Input/Output classes
|
by: Josh Strickland |
last post by:
I am attempting to create an Access database which uses forms to enter
data. The issue I am having is returning the query results from the
Stored Procedure back in to the Access Form.
tCetecM1CUST (SQL Table that contains the Customer Information)
tAccountingDetail (SQL Table that contains the information in the
form)
frmAccountingEntry (Access form used to enter data)
spGetCustomerInformation (Stored Procedure which returns data using...
|
by: alex.mcshane |
last post by:
Hi - I would be grateful for any knowledge regarding the following.
Whilst QAing Stored Procedures developed by colleagues, I noticed the
following 'superflous' parameter specifications:-
1) "Modifies SQL Data" - where the Stored Procedure is Select only.
In other words, the parameter should have been specified "Reads SQL
Data"
2) Result Sets 'n', where 'n' is > 0 - where the Stored Procedure does
| |
by: Jim Heavey |
last post by:
I have a SQL stored procedures which evaluate the values passed in parameters
and then based on those values reads the appropriate records.
I run the stored procedure in VS 2005 Debug mode and it successfully
executes and I can see the @@ROWCOUNT has the expected number of rows.
When I actually do this with my program, the datareader is returned with no
execption, but no rows are found in the reader.
So I change my Stored procedure...
|
by: satish mullapudi |
last post by:
Hi,
I am using DB2 v8.2 & jdk 1.4.
1. I have a java program which returns an array which contains 1 to 5
numbers.
The code:
public class ArrayTest
{
public static final int ARRAY_SIZE = 5;
public static int array()
{
|
by: aarnan |
last post by:
I have two SqlDataSources that use two different stored procedures that
take parameters to populate two controls, one dependant on an element
of the other.
The first data source, PreBuyDataSource is bound to PreBuyDetailsView
control and its parameters come from the session or request. The
stored procedure will always only find one row, and I found the
DetailsView control to be convenient.
The second data source, BudgetDataSource is...
|
by: acx |
last post by:
Dear Group,
I have got some XML code which I need to send from my SQL Server
database to some remote application server via POST method. The
application server will return XML code as well and this returned XML
will be processed on SQL Server afterwards.
Because of the fact that it all can't be done via T-SQL I was advised
on using CLR. This means that I should write some DLL in VB.NET or C#,
place this DLL on SQL Server, register it...
|
by: CSINVA |
last post by:
I have a stored procedure that returns columns from a table called
UserProfile. Within the table, it has a column called ProfielD,
PropertyValue, Visitbility. I need to be able set the values returned
to a variable to be used later. Here is an example of the data
without filtering stored procedure:
ProfileID, UserID, PropertyDefinitation, PropertyValue,Visibiity
31, 3, 20, Prefix, 2
32, 3, 22, Suffix, 2
33, 3, 25, unit, 2
|
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, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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...
|
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: 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...
|
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: 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...
| |