Hi,
My application bind to a database which have 2 table, man(manId, name, age) and employment(employId, manId, salary). manId in employment table is foreign key of man table.
I set the relationship of these two tables in MS Access. So after I add these two tables into my dataset, it automatically creates a “one-to-many” relation.
After I create a form, I drag the man table in dataset as ‘details’ onto my form, it create dataSet, manBindingSource, manTableAdapter, ManBindingNavigator. When I debug the application now, it works fine, can navigate, add, delete and update.
After that, I try to drag the employment table under manTable as “DataGridView” onto my form, it all work fine. All the fields from man and employment table can be ‘navigate’,’add’, ‘delete’ and ‘update’
Then I drag the employment table under the manTable as ‘details’ onto my form, it create EmploymentBindingSource and EmploymentTableAdapter.
Then I try to debug my application, I can navigate, add, delete and update those fields from my man table, but when I want to add data into employment table, it failed, for example, after fiiling all the details of man table, I fill in the ‘salary’ field of employment table, then I click ‘save’ button(I didn’t fill the employId and manId cause employId is auto-number and manId is foreign key of man table), all the three fields of employment table become blank. It didn’t save into my database, yet all the data in the man fields successfully save into my database.
I had spent more than a week to solve this problem, but still cannot.
I need to add those fields from table employment onto my form as ‘details’.
Can some one please help me?
Million thanks in advance.
Best regards
Boon.
p/s: I had already add code in the ‘save’ button of bindingNavigator so that it could save data to a database from multiple Tables. ( http://msdn2.microsoft.com/en-us/library/4esb49b4.aspx )
My application bind to a database which have 2 table, man(manId, name, age) and employment(employId, manId, salary). manId in employment table is foreign key of man table.
I set the relationship of these two tables in MS Access. So after I add these two tables into my dataset, it automatically creates a “one-to-many” relation.
After I create a form, I drag the man table in dataset as ‘details’ onto my form, it create dataSet, manBindingSource, manTableAdapter, ManBindingNavigator. When I debug the application now, it works fine, can navigate, add, delete and update.
After that, I try to drag the employment table under manTable as “DataGridView” onto my form, it all work fine. All the fields from man and employment table can be ‘navigate’,’add’, ‘delete’ and ‘update’
Then I drag the employment table under the manTable as ‘details’ onto my form, it create EmploymentBindingSource and EmploymentTableAdapter.
Then I try to debug my application, I can navigate, add, delete and update those fields from my man table, but when I want to add data into employment table, it failed, for example, after fiiling all the details of man table, I fill in the ‘salary’ field of employment table, then I click ‘save’ button(I didn’t fill the employId and manId cause employId is auto-number and manId is foreign key of man table), all the three fields of employment table become blank. It didn’t save into my database, yet all the data in the man fields successfully save into my database.
I had spent more than a week to solve this problem, but still cannot.
I need to add those fields from table employment onto my form as ‘details’.
Can some one please help me?
Million thanks in advance.
Best regards
Boon.
p/s: I had already add code in the ‘save’ button of bindingNavigator so that it could save data to a database from multiple Tables. ( http://msdn2.microsoft.com/en-us/library/4esb49b4.aspx )