By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,455 Members | 2,157 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,455 IT Pros & Developers. It's quick & easy.

DELETE CASCADE - Syntax Error in Constraint Clause (Error 3289)

P: n/a
HH
I try to make a script for generating backend databases. When I try to
make a relationship between a table named 'users' and another table
name 'layouts' an error occurs.

Option 1:
CurrentDB.Execute "ALTER TABLE layouts ADD CONSTRAINT users_layouts
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE"

Option 2:
DoCmd.RunSQL "ALTER TABLE layouts ADD CONSTRAINT users_layouts FOREIGN
KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE"

All environments are set to ANSI 92.

I prefer to use Option 1 which fails, Option 2 doesn't. Could anybody
give an explanation for this?

Jan 11 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"HH" <ha***********@hwits.nlwrote in message
<11**********************@i39g2000hsf.googlegroups .com>:
I try to make a script for generating backend databases. When I try
to make a relationship between a table named 'users' and another
table name 'layouts' an error occurs.

Option 1:
CurrentDB.Execute "ALTER TABLE layouts ADD CONSTRAINT users_layouts
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE"

Option 2:
DoCmd.RunSQL "ALTER TABLE layouts ADD CONSTRAINT users_layouts
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE"

All environments are set to ANSI 92.

I prefer to use Option 1 which fails, Option 2 doesn't. Could anybody
give an explanation for this?
If you need to use DDL, I think this can only be achieved through ADO
and the OLE DB provider, due to the "ON UPDATE CASCADE". For instance

CurrentProject.Connection.Execute _
"ALTER TABLE layouts ADD CONSTRAINT users_layouts " & _
"FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE"

See for instance
http://msdn2.microsoft.com/en-us/lib...ffice.10).aspx
for more info

--
Roy-Vidar
Jan 11 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.