2013-05-05 36 views
2

我有以下代碼數據庫親子連接problmen

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

的「未能啓用約束」當你有某種形式的數據庫架構錯誤的錯誤發生。

要解決這些問題:

  1. 確保您的主鍵不允許空值,而且沒有存儲任何空在那裏。

  2. 確保您的「關係」列(姓氏,來賓)非空,並且您尚未在其中存儲任何空值。

  3. 如果你改變了姓氏,遊客可以存儲,添加數據後的字符串的長度,你可以猛擊這裏遇到的問題:http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvb/thread/27aec612-5ca4-41ba-80d6-0204893fdcd1/