Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delphi and database problem

Status
Not open for further replies.

sancho1980

Technical User
Nov 25, 2005
15
DE
Hello people I do have a problem with Delphi and databases so I didnt know whether to post this in the Delphi or the Database forum so I just decided to post it in both. I have defined a database in Access which has several tables (which are not all relevant for my question), anyway this is important: there is one table (dictionaryEntries) which is related to another table (synonyms). I have created this relation in Access directly with referential integrity; one dictionaryEntries record can therefore relate to several synonyms records. The relation is drawn between the primary key (recID) of my dictionaryEntries table and a field called entryID in the synonym table.
Now suppose I DO have an entry in my dictionaryEntries table with the primary key 1. If I now add a synonym to my synonyms table with the entryID field containing 1 (meaning that this synonym relates to record 1 of my dictionaryEntries table) I still get an EOIeEXCEPTION telling me that there must be a record in the dictionaryEntries table relating to the new record. Why does the database engine not realize that there is indeed already a record in my dictionaryEntries table with this primary key?? Does any of you have an idea?
Thanx Martin.

PS: Here is the insert function:

function TDM_Dictionary.InsertASSynonym(ASSynonym: TSynonym): Integer;
var
GenderPK: Integer;
begin
if dictionaryEntryExists(ASSynonym.entryID) then
if self.GetASSynonymPK(ASSynonym) = -1 then
begin
self.QRY_InsertASSynonym.SQL.Clear();
self.QRY_InsertASSynonym.SQL.Add(MakeInsertASSynonymSQL(ASSynonym));
if Length(ASSynonym.Gender) <> 0 then
begin
GenderPK := self.InsertGender(ASSynonym.Gender);
self.QRY_InsertASSynonym.Parameters.ParamByName('GEN').Value := GenderPK;
end;
self.QRY_InsertASSynonym.Parameters.ParamByName('SYN').Value := ASSynonym.Synonym;
self.QRY_InsertASSynonym.Parameters.ParamByName('ENTRYID').Value := ASSynonym.entryID;
if Length(ASSynonym.PRGM) <> 0 then
self.QRY_InsertASSynonym.Parameters.ParamByName('PRGM').Value := ASSynonym.PRGM;
self.QRY_InsertASSynonym.ExecSQL();
InsertASSynonym := self.GetASSynonymPK(ASSynonym);
end
else InsertASSynonym := self.GetASSynonymPK(ASSynonym)
else
InsertASSynonym := -1;
end;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top