访问关系(在更新级联上) [英] Relationship to access ( on update cascade )

查看:58
本文介绍了访问关系(在更新级联上)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在开发一个需要在Access数据库中创建数据库和表的程序.
我需要创建关系并配置对Cascade的On更新,对于Delete也是相同的(我已经尝试了适用于SQL和MySQL的基本语法,但是它不能与访问一起使用,显然"update"会导致语法问题) .所以=>

首先:
-是否可以访问?

第二:
-如果是的话,我该如何解决?

解决方案

您没有提及正在使用的技术,但是我发现了这个

报价:

 OledbConnection con =  OledbConnection( " );
con.Open();

// 添加主键
OledbCommand comm =  OledbCommand(" ,con);
comm.ExecuteNonQuery();

// 添加外键
comm =  OledbCommand(" ,con);
comm.ExecuteNonQuery();

来自 Microsoft Access中的级联更新 [
错误消息是语法不正确".

在使用"ALTER table"创建表后,我尝试过在创建表时配置该关系,但是仍然显示相同的错误消息=(

有人可以帮我吗?


Hi everyone,

I''m working on a program that need to create databases and tables in a access database.
I need to create relationship and configure the On update to Cascade and same for on delete ( i''ve tryed the basic syntacs that works on SQL and MySQL but it dosn''t work with access, apparently "update" causes syntacs problems ). So =>

First :
-Is it possible on access ?

Second :
-And if yes,how can i acheve it ?

You did not mention which technology you are using but I found this

Quote:

OledbConnection con = new OledbConnection("Connection String");
con.Open();

//Adding Primary Key
OledbCommand comm = new OledbCommand("alter table Table1 add constraint pk_id primary key(id)",con);
comm.ExecuteNonQuery();

//Adding Foriegn Key
comm = new OledbCommand("alter table Table2 add constraint fk_id foreign key(id) references Table1(id)",con);
comm.ExecuteNonQuery();

con.Close();

from Creating relations in MS Access with C#[^].


Take a look at Cascade Updates in Microsoft Access[^] article.


Thank you very much for replying so quick, =)

But i need to create programaticaly the relation and i absolutly need the ON UPDATE and ON DELETE option to work.

The creation of the relation works but when i had "ON UPDATE" or "ON DELETE" it fails,
the error message is "syntax incorrect".

I''ve tryed a to configure the relation while creating the table, after creating it with "ALTER table" but still the same error message shows up =(

Can someone help me ??


这篇关于访问关系(在更新级联上)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆