473,396 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Parameter.Add need help - not understanding

Hello,
I'm somewhat new to DB programming and have a question. I am now taking
over an application that a previous programmer had written and he had
made use of the Parameter.Add function for DB2 comman objects. This is
what is trying to be done:

An sql statement is created that uses ? as value markers. This value is
passed into a function that calls the Parameter.Add function. What is
supposed to happen is that the first ? is replaced with the value
passed to the function. What is happening is that ALL of the ? markers
are replaced, not just the first one. Here is an example sql statement
and function call:
*note I am using vb.net*

SELECT test_one, test_two
FROM mydb.test_param
WHERE test_three = ?
AND test_four = ?

db.AddParameter(tstParam) // this is the function call
CType(Cmnd,DB2Command).Parameters.Add("aParam",tst Param)) // this is
the db2 function call.

Ok now if the AddParameter call is made once before executing the sql
statement it appears to work fine. But if there is more than one call
of AddParameter before the sql statement is executed then there is an
error. What happens is that when the Parameters.Add db2 function is
called it is replacing both ? markers instead of just the first one.
Does anyone have a suggestion on how to make it replace only the first
one or a better way of doing this function?

Thanks in advance for any and all help.

Apr 3 '06 #1
1 1983
Vaelek wrote:
Hello,
I'm somewhat new to DB programming and have a question. I am now taking
over an application that a previous programmer had written and he had
made use of the Parameter.Add function for DB2 comman objects. This is
what is trying to be done:

An sql statement is created that uses ? as value markers. This value is
passed into a function that calls the Parameter.Add function. What is
supposed to happen is that the first ? is replaced with the value
passed to the function. What is happening is that ALL of the ? markers
are replaced, not just the first one. Here is an example sql statement
and function call:
*note I am using vb.net*

SELECT test_one, test_two
FROM mydb.test_param
WHERE test_three = ?
AND test_four = ?

db.AddParameter(tstParam) // this is the function call
CType(Cmnd,DB2Command).Parameters.Add("aParam",tst Param)) // this is
the db2 function call.

Ok now if the AddParameter call is made once before executing the sql
statement it appears to work fine. But if there is more than one call
of AddParameter before the sql statement is executed then there is an
error. What happens is that when the Parameters.Add db2 function is
called it is replacing both ? markers instead of just the first one.
Does anyone have a suggestion on how to make it replace only the first
one or a better way of doing this function?


It would be good to know the programming language you are using.

As for the problem, you should use an additional parameter for the
AddParameter routine so that the routine knows which parameter marker the
provided value is for. Or you use some implicit counting inside the
function...

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Apr 3 '06 #2

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

Similar topics

5
by: Brandolon Hill | last post by:
Hi, Is there a way to check and see if a parameter is defined in XSLT? I have many stylesheets that all have an <xsl:include> of the same stylesheet, "foo.xsl". Foo relies on several...
18
by: hzmonte | last post by:
typedef int t_compare_func(const void *, const void *); struct node *tree_search(struct node *root, const void *keyy, t_compare_func *comp) { struct node *cur_item; int result; if (root ==...
15
by: Scott W Gifford | last post by:
Hello, We've got a Web-based application written in Perl that is designed to integrate as a frame into many different Web sites. We currently have several stylesheets available to allow the...
16
by: hzmonte | last post by:
Correct me if I am wrong, declaring formal parameters of functions as const, if they should not be/is not changed, has 2 benefits; 1. It tells the program that calls this function that the...
1
by: rosie2006 | last post by:
Environment: .net2.0 over oracle Problem? a simple select statement within a DetailsView that gets two parameter values from a GridView SelectedValue. It might be valuable to understand that to...
8
by: =?Utf-8?B?UmF2aQ==?= | last post by:
Hi, I'm trying to pass values of different data-types to a web-service. I thought it would be easier to box these values and pass them as a System.object parameter, like public void...
10
by: Woody Ling | last post by:
In 32 bits DB2 environment, is it meaningful to set sheapthres larger than 256MB for the following case.. 1. Intra-parallel is ON 2. Intra-parallel is OFF
2
by: | last post by:
I have a gridview with a textbox in an ItemTemplate, as below. The OnTextChanged event fires okay but how do I pass a parameter to it, I get an error when I try "OnTextChanged(""SomeData"")". I...
5
by: puzzlecracker | last post by:
C++ standard says the following: I am reading through c++ standard and have a difficulty understanding the difference between these two terms. Thanks, puzzlecracker
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
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...
0
tracyyun
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...
0
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,...

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.