BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Parameter linked to datasource problem

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder Databases (InterBase Express)
View previous topic :: View next topic  
Author Message
M
Guest





PostPosted: Wed Jan 11, 2006 5:20 am    Post subject: Parameter linked to datasource problem Reply with quote



I've got a master/detail relationship setup between 2 TIBDataSet's. SQL is as follows:

Master (qryItem) SelectSQL:
SELECT ITEMID, TITLE, TITLE2, SORT_TITLE, GENREID, RATINGID,
DISTRIBUTORID, VIEW_FORMATID, CREATE_DATE, PRINT_IN_SUPP, PRINT_IN_PLATTERLOG, FILMYEAR, SECTIONID,
RPT_FIELDTOSHOW, INTELLICAPS, LAST_MODIFIED
FROM ITEM
WHERE ITEMID = :ITEMID

Detail (qryActors) SelectSQL:
SELECT ACTORS.DISPLAYNAME AS "Actor", ACTORITEM.ACTORID
FROM ACTORITEM
LEFT JOIN ACTORS ON ACTORITEM.ACTORID = ACTORS.ACTORID
WHERE ACTORITEM.ITEMID = :ITEMID
ORDER BY ACTORS.DISPLAYNAME ASC

Detail (qryActors) DeleteSQL:
DELETE
FROM ACTORITEM
WHERE ACTORID = :ACTORID
AND ITEMID = :ITEMID

I added a TIBSQLMonitor and it shows the following parameters for the preceeding queries when they
are executed:

qryItem/SelectSQL:
ITEMID = 282

qryActors/SelectSQL:
ITEMID = 282

qryActors/DeleteSQL:
ACTORID = 458
ITEMID = 0

qryActors' DataSource property is set to dsItem, who's DataSet property is set to qryItem. As you
can see there's no problem finding the corresponding ITEMID when qryActors is Open()ed, but when I
call Delete() the ITEMID parameter has changed to 0. Even if I try setting the value of the
parameter manually before Delete() it still shows ITEMID as being 0 in the SQLMonitor.

The only code in between qryActors being opened and Delete() being called is:

AnsiString Actor = qryActors->FieldByName("Actor")->AsString;
AnsiString Message = "Are you sure to want to delete \'" + Actor +"\'?";

if (MessageDlg(Message, mtConfirmation, mbOKCancel, 0) == mrOk) {

Does anyone have any idea what could be going wrong with the ITEMID paramter when Delete() is called
for qryActors?

TIA
Mark
Back to top
Jeff Overcash (TeamB)
Guest





PostPosted: Thu Jan 12, 2006 5:57 pm    Post subject: Re: Parameter linked to datasource problem Reply with quote



M wrote:
Quote:
I've got a master/detail relationship setup between 2 TIBDataSet's. SQL
is as follows:

Master (qryItem) SelectSQL:
SELECT ITEMID, TITLE, TITLE2, SORT_TITLE, GENREID, RATINGID,
DISTRIBUTORID, VIEW_FORMATID, CREATE_DATE, PRINT_IN_SUPP,
PRINT_IN_PLATTERLOG, FILMYEAR, SECTIONID,
RPT_FIELDTOSHOW, INTELLICAPS, LAST_MODIFIED
FROM ITEM
WHERE ITEMID = :ITEMID

Detail (qryActors) SelectSQL:
SELECT ACTORS.DISPLAYNAME AS "Actor", ACTORITEM.ACTORID
FROM ACTORITEM
LEFT JOIN ACTORS ON ACTORITEM.ACTORID = ACTORS.ACTORID
WHERE ACTORITEM.ITEMID = :ITEMID
ORDER BY ACTORS.DISPLAYNAME ASC

Detail (qryActors) DeleteSQL:
DELETE
FROM ACTORITEM
WHERE ACTORID = :ACTORID
AND ITEMID = :ITEMID

I added a TIBSQLMonitor and it shows the following parameters for the
preceeding queries when they are executed:

qryItem/SelectSQL:
ITEMID = 282

qryActors/SelectSQL:
ITEMID = 282

qryActors/DeleteSQL:
ACTORID = 458
ITEMID = 0

qryActors' DataSource property is set to dsItem, who's DataSet property
is set to qryItem. As you can see there's no problem finding the
corresponding ITEMID when qryActors is Open()ed, but when I call
Delete() the ITEMID parameter has changed to 0. Even if I try setting
the value of the parameter manually before Delete() it still shows
ITEMID as being 0 in the SQLMonitor.

The only code in between qryActors being opened and Delete() being
called is:

AnsiString Actor = qryActors->FieldByName("Actor")->AsString;
AnsiString Message = "Are you sure to want to delete \'" + Actor +"\'?";

if (MessageDlg(Message, mtConfirmation, mbOKCancel, 0) == mrOk) {

Does anyone have any idea what could be going wrong with the ITEMID
paramter when Delete() is called for qryActors?

TIA
Mark

You have to also bring back ItemID in the detail query since you want to use
that FIELD in your delete statement. Parameters in the InsertSQL, ModifySQL,
DeleteSQL and RefreshSQL are always replaced by field values, but you do not
have a field called ItemID.

--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
A human being should be able to change a diaper, plan an invasion, butcher
a hog, conn a ship, design a building, write a sonnet, balance accounts, build
a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act
alone, solve equations, analyze a new problem, pitch manure, program a computer,
cook a tasty meal, fight efficiently, die gallantly. Specialization is for
insects. (RAH)
Back to top
M
Guest





PostPosted: Fri Jan 13, 2006 1:58 am    Post subject: Re: Parameter linked to datasource problem Reply with quote



That worked. Thank you.

Mark
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder Databases (InterBase Express) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.