Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Delphi help - SQL INSERT INTO problem?
Index -> General Discussion
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
haglerfan




PostPosted: Sat Apr 16, 2011 12:54 pm   Post subject: Delphi help - SQL INSERT INTO problem?

I am trying to insert some information from my delphi program into a table that is linked to another table via a relationship.

The 3 tables in the database are as follows:


Table name = tblFight

Fields:

ID (primary key)
Bout
Weight Division



Table Name = tblFighter

Fields:

ID (primary key)
Fighter Name
Fighter Surname



Table Name = tblScore

Fields:

ID (primary key)
Score
Round
FighterID (foreign key that is linked to tblFighter.ID)
FightID (foreign key that is linked to tblFight.ID)



What I am trying to do in the program is input the score of each fighter (boxer) for each round.


This is my preset code:

ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('Insert into Score ([Score],[Round],[FighterID],[FightID]) Values('+quotedstr(cbrf1.text)+','+QuotedStr(inttostr(countround))+',tblFighter.ID ,tblFight.ID )');
ADOQuery1. ExecSQL;

The "tblFighter.ID" and tblFight.ID" bring up an error message saying "tblFighter.ID has no default value".

I'm not sure what to do.
Sponsor
Sponsor
Sponsor
sponsor
haglerfan




PostPosted: Sat Apr 16, 2011 2:43 pm   Post subject: RE:Delphi help - SQL INSERT INTO problem?

bump
haglerfan




PostPosted: Sun Apr 17, 2011 6:51 am   Post subject: RE:Delphi help - SQL INSERT INTO problem?

bump
haglerfan




PostPosted: Sun Apr 17, 2011 12:15 pm   Post subject: RE:Delphi help - SQL INSERT INTO problem?

Please someone help.

You all supposedly know about programming...
Tony




PostPosted: Sun Apr 17, 2011 12:50 pm   Post subject: RE:Delphi help - SQL INSERT INTO problem?

I would imagine that the string "tblFighter.ID" is not a valid ID.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
haglerfan




PostPosted: Sun Apr 17, 2011 1:15 pm   Post subject: RE:Delphi help - SQL INSERT INTO problem?

And that means....


What code must I type?
2goto1




PostPosted: Tue Apr 19, 2011 10:39 am   Post subject: RE:Delphi help - SQL INSERT INTO problem?

You're trying to insert tblFighter.ID and tblFight.ID. Those are column names, rather than specific values.

You have to specify specific field values to insert rather than just column names. Similar to what you did for specifying score and round.
Display posts from previous:   
   Index -> General Discussion
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: