数据库父子连接问题

时间:2013-05-05 23:37:44

标签: vb.net winforms ado.net dataadapter

我有以下代码

 Imports System.Data


 Public Class ReservationList

Private Sub GuestListToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GuestListToolStripMenuItem.Click
    'Show the registration table

    GuestListForm.Show()
    Me.Hide()
End Sub

Private Sub HighriseToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HighriseToolStripMenuItem.Click
    ' Shows the About Box
    highriseAboutBox.Show()
End Sub

Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
    ' Terminates program
    highriseAboutBox.Show()
    Me.Close()
End Sub

Private Sub NewReservationToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewReservationToolStripMenuItem.Click
    ' Restarts the program
    NewReservationForm.Show()
    Me.Close()
End Sub

Private Sub ExitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButton.Click
    ' terminates program

    highriseAboutBox.Show()
    Me.Close()
End Sub

Private Sub ReservationList_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    'TODO: This line of code loads data into the 'CottagesDataSet.Guests' table. You can move, or remove it, as needed.
    Me.GuestsTableAdapter.Fill(Me.CottagesDataSet.Guests)
    'TODO: This line of code loads data into the 'CottagesDataSet.Reservations' table. You can move, or remove it, as needed.
    Me.ReservationsTableAdapter.Fill(Me.CottagesDataSet.Reservations)

End Sub

Private Sub Last_NameLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

End Sub


Private Sub Last_NameComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Last_NameComboBox.SelectedIndexChanged

End Sub
End Class

当我运行(调试)程序时,我得到了这个

enter image description here

我正在尝试设置父子关系,如下所示:

enter image description here

这是我的.xsd关系

enter image description here

所以我只能告诉你。知道为什么我会收到这个错误吗?一切似乎检查我设置相同的另一个数据库。我也按照书籍教程,没有错过任何东西。我接近抛弃整个想法,但我想让它发挥作用。

由于

1 个答案:

答案 0 :(得分:1)

当您遇到某种形式的数据库架构错误时,会出现“无法启用约束”错误。

修复它们:

  1. 确保您的主键不允许使用空值,并且尚未存储任何空值。

  2. 确保您的'关系'列(姓氏,来宾)非空,并且您尚未存储任何空值。

  3. 如果您更改了姓氏,客人可以存储的字符串的长度,在添加数据后,您可能会遇到此处遇到的问题:http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvb/thread/27aec612-5ca4-41ba-80d6-0204893fdcd1/