Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
kenharding
Starting Member
1 Post |
Posted - 2007-04-18 : 01:58:11
|
Hello all,I'm programming in VB and learning sql databases and I have created a database with the following 3 files:File1: ProjectHeadProjectID (primary key)DataItem1DataItem2File2: DataSheetListDataSheetID (primary key)DataItem1DataItem2ProjectID (foreign key which relates to primary key in ProjectHead)File3: DataSheetHeadDataHeadID (primary key)DataItem1DataItem2DataSheetID (foreign key which relates to primary key in DataSheetList)In my program I brows down ProjectHead and when an entry is found DataSheetList is examined and all the entries that have a matching foreign key with ProjectHead's primary key are placed in a list box control (DataItem1 from DataSheetList is put in the listbox). When the user selects an entry in the listbox (there may be several) the corresponding entry in DataSheetHead is loaded into a Detailed View (as apposed to a Data grid view) form.Getting the correct data to appear on the screen is working fine.If the user selects the first entry in the listview and edits the data in DataSheetHead that pops up on the screen and saves that data away again all is ok.However, if the user selects the second entry (or third, or fourth etc) from the listview, the correct data is appearing on the screen but when that data is edited and the save button is pressed no data is being written away.I have stripped all the data from all of the files and carefully re-populated them to make sure that my keys and foreign keys are pointing to the correct files. When I select the data from the listbox the correct data is being written into the textboxes on my screen. It doesn't matter how many entries I have in the listbox, only the first record is written to the file correctly.What is confusing me here is that when I brows through the files all the correct data is being written to the screen and when I edit and save the data for record 1 from DataSheetHead it is working fine. It only goes wrong when I try to edit record 2 or 3 and so on.Please note that for every entry in the listbox, there is only ever one entry in the DataSheetHead file.Here is my code:Public Class formOne Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.DataSheetHeadTableAdapter.Fill(Me.PcmDataSet.DataSheetHead) Me.DataSheetListTableAdapter.Fill(Me.PcmDataSet.DataSheetList) Me.ProjectHeadTableAdapter.Fill(Me.PcmDataSet.ProjectHead) End Sub Private Sub ProjectHeadBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _Handles ProjectHeadBindingNavigatorSaveItem.Click Dim a As Integer = 0 Me.Validate() Me.DataSheetHeadBindingSource.EndEdit() a = Me.DataSheetHeadTableAdapter.Update(Me.PcmDataSet.DataSheetHead) MsgBox(a & " data sheet head updated") End Sub End Class Thanks for lookingKen |
|
|
|
|
|