Computer Science Canada Delphi help - SQL INSERT INTO problem? |
Author: | haglerfan [ 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. |
Author: | haglerfan [ Sat Apr 16, 2011 2:43 pm ] |
Post subject: | RE:Delphi help - SQL INSERT INTO problem? |
bump |
Author: | haglerfan [ Sun Apr 17, 2011 6:51 am ] |
Post subject: | RE:Delphi help - SQL INSERT INTO problem? |
bump |
Author: | haglerfan [ 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... |
Author: | Tony [ 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. |
Author: | haglerfan [ Sun Apr 17, 2011 1:15 pm ] |
Post subject: | RE:Delphi help - SQL INSERT INTO problem? |
And that means.... What code must I type? |
Author: | 2goto1 [ 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. |