【发布时间】:2016-10-23 19:25:36
【问题描述】:
我正在尝试在两个表之间创建关系。 用户选择第一个表 (choice1) 然后选择第二个表 (choice2) 并选择第二个表 (field2) 中的字段。然后他给关系命名(namerelationship)
我收到此错误
索引或关系定义中的字段定义“ForeignKey”无效
string namerelationship = txtNameRelationship.Text;
string choice1 = cboTable1.SelectedItem.ToString();
string choice2 = cboTable2.SelectedItem.ToString();
string field2 = cboField2.SelectedItem.ToString();
Relation myrel = clsDataSource.mydb.CreateRelation(namerelationship, choice1, choice2);
Field myfield = new Field();
myfield = myrel.CreateField(choice1);
myfield.ForeignName = "ForeignKey";
myrel.Fields.Append(myfield);
clsDataSource.mydb.Relations.Append(myrel);
【问题讨论】:
-
您能解释一下您在使用上述代码时遇到了什么问题吗?
-
我用我的错误更新了它
-
你为什么不对下面的
C# DataSource.CreateRelation进行谷歌搜索,看来你目前这样做不正确 -
您已使用比 ADO 更早的 DAO 标记了此问题。您使用的是哪个库?
-
我在这个项目中使用 DAO