Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / DB2 Topics / April 2006

Tip: Looking for answers? Try searching our database.

Parameter.Add need help - not understanding

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Vaelek - 03 Apr 2006 15:43 GMT
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",tstParam)) // 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.
Knut Stolze - 03 Apr 2006 18:59 GMT
> Hello,
> I'm somewhat new to DB programming and have a question. I am now taking
[quoted text clipped - 26 lines]
> 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...

Signature

Knut Stolze
DB2 Information Integration Development
IBM Germany

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.