syntax error in CONSTRAINT clause
-
I'm trying to use C# to add a column to an MS Access database, but I'm having trouble with the syntax. My SQL string amounts to something like this:
ALTER TABLE t_customer ADD person_id integer CONSTRAINT FK_person_id FOREIGN KEY (person_id) REFERENCES t_person (person_id)
I can't find any difference to the MSDN example syntax. Can you tell me where the error is? Thanks! -
I'm trying to use C# to add a column to an MS Access database, but I'm having trouble with the syntax. My SQL string amounts to something like this:
ALTER TABLE t_customer ADD person_id integer CONSTRAINT FK_person_id FOREIGN KEY (person_id) REFERENCES t_person (person_id)
I can't find any difference to the MSDN example syntax. Can you tell me where the error is? Thanks!Megidolaon wrote:
My SQL string amounts to something like this
"Something like that" should work.
Megidolaon wrote:
Can you tell me where the error is?
Not without seeing your code, but I could do an educated guess. You're referring to this[^] example? The example on that page lists this code;
' Add a foreign key to the Orders table.
dbs.Execute "ALTER TABLE Orders " _
& "ADD CONSTRAINT OrdersRelationship " _
& "FOREIGN KEY (EmployeeID) " _
& "REFERENCES Employees (EmployeeID);"Are you concatenating strings the same way? If so, check the resulting string - it may be missing the space at the end of each line; between "Orders" and "ADD", between "OrdersRelationShip" and "FOREIGN" and between ")" and "REFERENCES".
I are Troll :suss: