 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Jon Scott Guest
|
Posted: Sat Feb 28, 2004 7:35 pm Post subject: TADOQuery - using 2 detail parameters for same master field |
|
|
I use TADOQuery on an Access database and have a master/detail relationship between two tables.
On the detail table SQL, I have something like:
SELECT * FROM Detail
WHERE ((Detail.Field1 LIKE '%' + :PARENTFIELD + '%')
OR (Detail.Field2 = :PARENTFIELD))
However, I notice that TADOQuery only fills in the first parameter and ignores the second one
(it is null). The only way I can get this to work is to manually fill in the parameters
whenever a user moves between records on the master table and Requery the detail table. Is
there a way to make this work using TADOQuery or another ADO descendant component (freeware)?
Does using TADODataSet or TADOTable make any difference? I have yet to try those.
--
Thanks,
Jon E. Scott
Blue Orb Software
http://www.blueorbsoft.com
|
|
| Back to top |
|
 |
Jon Scott Guest
|
Posted: Sat Feb 28, 2004 7:39 pm Post subject: Re: TADOQuery - using 2 detail parameters for same master fi |
|
|
And if it makes any difference, I'm using D5 Ent.
--
Thanks,
Jon E. Scott
Blue Orb Software
http://www.blueorbsoft.com
"Jon Scott" <NOSPAMsupport (AT) blueorbsoft (DOT) comNOSPAM> wrote
| Quote: | I use TADOQuery on an Access database and have a master/detail relationship between two
tables.
On the detail table SQL, I have something like:
SELECT * FROM Detail
WHERE ((Detail.Field1 LIKE '%' + :PARENTFIELD + '%')
OR (Detail.Field2 = :PARENTFIELD))
However, I notice that TADOQuery only fills in the first parameter and ignores the second one
(it is null). The only way I can get this to work is to manually fill in the parameters
whenever a user moves between records on the master table and Requery the detail table. Is
there a way to make this work using TADOQuery or another ADO descendant component (freeware)?
Does using TADODataSet or TADOTable make any difference? I have yet to try those.
--
Thanks,
Jon E. Scott
Blue Orb Software
http://www.blueorbsoft.com
|
|
|
| Back to top |
|
 |
Jon Scott Guest
|
Posted: Sun Feb 29, 2004 3:19 am Post subject: Re: TADOQuery - using 2 detail parameters for same master fi |
|
|
Of course, you can name a parameter whatever you want, but for TADOQuery, it must be the master
table's fieldname. How else would it know what field to get the value from? Try it out and
you'll see what I mean.
--
Thanks,
Jon E. Scott
Blue Orb Software
http://www.blueorbsoft.com
"Brian Bushay TeamB" <BBushay (AT) Nmpls (DOT) com> wrote
| Quote: | I use TADOQuery on an Access database and have a master/detail relationship between two
tables.
On the detail table SQL, I have something like:
SELECT * FROM Detail
WHERE ((Detail.Field1 LIKE '%' + :PARENTFIELD + '%')
OR (Detail.Field2 = :PARENTFIELD))
However, I notice that TADOQuery only fills in the first parameter and ignores the second one
(it is null). The only way I can get this to work is to manually fill in the parameters
whenever a user moves between records on the master table and Requery the detail table. Is
there a way to make this work using TADOQuery or another ADO descendant component (freeware)?
Does using TADODataSet or TADOTable make any difference? I have yet to try those.
--
ADO doesn't support parameters of the same name in a query. Rename your second
parameter and your query will work.
--
Brian Bushay (TeamB)
[email]Bbushay (AT) NMPLS (DOT) com[/email]
|
|
|
| Back to top |
|
 |
Jon Scott Guest
|
Posted: Sun Feb 29, 2004 5:57 pm Post subject: Re: TADOQuery - using 2 detail parameters for same master fi |
|
|
Yes, that's exactly what I'm doing, but thought there was a way I didn't have to do it manually.
Thanks anyway.
--
Jon E. Scott
Blue Orb Software
http://www.blueorbsoft.com
"Brian Bushay TeamB" <BBushay (AT) Nmpls (DOT) com> wrote
| Quote: |
Of course, you can name a parameter whatever you want, but for TADOQuery, it must be the
master
table's fieldname. How else would it know what field to get the value from? Try it out and
you'll see what I mean.
The SQL passed to ADO can't have parameters of the same name.
Borlands ADO components are not going to maintain master/Detail with your SQL.
You will need to change the name of one of the parameters then write code for
the master tables AfterScroll event to handle setting the detail table
parameters and then REQUERY
--
Brian Bushay (TeamB)
[email]Bbushay (AT) NMPLS (DOT) com[/email]
|
|
|
| Back to top |
|
 |
Vitali Kalinin Guest
|
Posted: Mon Mar 01, 2004 9:38 am Post subject: Re: TADOQuery - using 2 detail parameters for same master fi |
|
|
In this specific case you can adjust yours SQL like this:
SELECT * FROM Detail
WHERE ((Detail.Field1 LIKE '%' + Detail.Field2 + '%')
OR (Detail.Field2 = :PARENTFIELD))
"Jon Scott" <NOSPAMsupport (AT) blueorbsoft (DOT) comNOSPAM> сообщил/сообщила в
новостях следующее: news:4042280c$1 (AT) newsgroups (DOT) borland.com...
| Quote: | Yes, that's exactly what I'm doing, but thought there was a way I didn't
have to do it manually.
Thanks anyway.
--
Jon E. Scott
Blue Orb Software
http://www.blueorbsoft.com
"Brian Bushay TeamB" <BBushay (AT) Nmpls (DOT) com> wrote in message
news:390440h4q1lk3a80j93klbituttrdci29d (AT) 4ax (DOT) com...
Of course, you can name a parameter whatever you want, but for
TADOQuery, it must be the
master
table's fieldname. How else would it know what field to get the value
from? Try it out and
you'll see what I mean.
The SQL passed to ADO can't have parameters of the same name.
Borlands ADO components are not going to maintain master/Detail with
your SQL.
You will need to change the name of one of the parameters then write
code for
the master tables AfterScroll event to handle setting the detail table
parameters and then REQUERY
--
Brian Bushay (TeamB)
[email]Bbushay (AT) NMPLS (DOT) com[/email]
|
|
|
| Back to top |
|
 |
Vitali Kalinin Guest
|
Posted: Mon Mar 01, 2004 10:55 am Post subject: Re: TADOQuery - using 2 detail parameters for same master fi |
|
|
Sorry this won't work
"Vitali Kalinin" <vitkalinin (AT) yahoo (DOT) com> сообщил/сообщила в новостях
следующее: news:40430525 (AT) newsgroups (DOT) borland.com...
| Quote: | In this specific case you can adjust yours SQL like this:
SELECT * FROM Detail
WHERE ((Detail.Field1 LIKE '%' + Detail.Field2 + '%')
OR (Detail.Field2 = :PARENTFIELD))
"Jon Scott" <NOSPAMsupport (AT) blueorbsoft (DOT) comNOSPAM> сообщил/сообщила в
новостях следующее: news:4042280c$1 (AT) newsgroups (DOT) borland.com...
Yes, that's exactly what I'm doing, but thought there was a way I didn't
have to do it manually.
Thanks anyway.
--
Jon E. Scott
Blue Orb Software
http://www.blueorbsoft.com
"Brian Bushay TeamB" <BBushay (AT) Nmpls (DOT) com> wrote in message
news:390440h4q1lk3a80j93klbituttrdci29d (AT) 4ax (DOT) com...
Of course, you can name a parameter whatever you want, but for
TADOQuery, it must be the
master
table's fieldname. How else would it know what field to get the
value
from? Try it out and
you'll see what I mean.
The SQL passed to ADO can't have parameters of the same name.
Borlands ADO components are not going to maintain master/Detail with
your SQL.
You will need to change the name of one of the parameters then write
code for
the master tables AfterScroll event to handle setting the detail table
parameters and then REQUERY
--
Brian Bushay (TeamB)
[email]Bbushay (AT) NMPLS (DOT) com[/email]
|
|
|
| Back to top |
|
 |
Mike Walsh Guest
|
Posted: Wed Mar 03, 2004 1:56 pm Post subject: Re: TADOQuery - using 2 detail parameters for same master fi |
|
|
"Jon Scott" <NOSPAMsupport (AT) blueorbsoft (DOT) comNOSPAM> wrote
| Quote: | Yes, that's exactly what I'm doing, but thought there was a way I didn't
have to do it manually.
Thanks anyway.
Jon, |
Several times to other posters, I've mentioned in these groups a method that
I use, and noone has ever commented on it. So, I don't know if there's any
reason not to use it, but I do and it works (at least against Microsoft SQL
Server). What I do is include a variable in my script, then set the var =
parameter, then my where clause uses the var instead. For example your query
would be
declare
@ParentField varchar (200) -- or whatever it is
set @ParentField = :ParentField
SELECT * FROM Detail
WHERE ((Detail.Field1 LIKE '%' + @ParentField + '%')
OR (Detail.Field2 = :@ParentField))
If any gurus out there see a problem with this approach, I'd love to hear
about it.
Mike Walsh
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|