Author |
Message |
haglerfan
|
Posted: 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
|
|
|
haglerfan
|
Posted: Sat Apr 16, 2011 2:43 pm Post subject: RE:Delphi help - SQL INSERT INTO problem? |
|
|
bump |
|
|
|
|
|
haglerfan
|
Posted: Sun Apr 17, 2011 6:51 am Post subject: RE:Delphi help - SQL INSERT INTO problem? |
|
|
bump |
|
|
|
|
|
haglerfan
|
Posted: 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
|
Posted: 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. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
haglerfan
|
Posted: 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
|
Posted: 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. |
|
|
|
|
|
|