Update-add field-Datagrid use Bindingsource (not use SQL)

alone76816

New member
Joined
Mar 8, 2011
Messages
1
Programming Experience
Beginner
[FONT=&quot]1. I have a problem as below: I have a Database, include 3 Table : TBLHocVien, TBLDiem, TBLDiemDanh, all this Table have RelationShip by Field: MaHV.[/FONT]
[FONT=&quot]1. [/FONT][FONT=&quot] I make a Connect with this databse, but I don’t use Command SQL, I make connect to Database by Winzard in VB.Net 2005.[/FONT]

[FONT=&quot][/FONT]


[FONT=&quot]I Add Row, Edit, Delete,or Update by VB.net it’s OK. But then I opened Database by Access and I add more a few Table or Field, then VB.net is nothing. So How do I add Field or Table by ways : BindingSource ? [/FONT]
[FONT=&quot]Ex :[/FONT]
[FONT=&quot]Me.Validate()
Me.TBLDIEMDANHBindingSource.EndEdit()
Me.TBLDIEMDANHTableAdapter.Update(Me.DatabaseDataSet.TBLDIEMDANH)[/FONT]

[FONT=&quot]2. [/FONT][FONT=&quot]2. The Second Problem is : when I edit DataSet in Window DataSource[/FONT]


[FONT=&quot]
editdataset.jpg
[/IMG[/URL]][/FONT]

[FONT=&quot]And I add more a Column : TenHV Form Table TBLHocVien to Table TBLDiem by ways Query as below:[/FONT]



[FONT=&quot]
configdataset.jpg
[/IMG[/URL]][/FONT]



[FONT=&quot]
addfield.jpg
[/IMG[/URL]][/FONT]



[FONT=&quot]And the result on Dateset show as below:[/FONT]

[FONT=&quot]
datasourcesaukhiedit.jpg
[/IMG[/URL]][/FONT]

[FONT=&quot]DataGrid of table TBLDiem as below:[/FONT]


[FONT=&quot]
datagrid.jpg
[/IMG[/URL]][/FONT]

[FONT=&quot]The result : Column TenHV on DataGrid show OK as TBLHocVien. But when I Run and I edit value Column on DataGrid. And I Update to Database, it’s nothing. I can’t. I use:[/FONT]
[FONT=&quot]Me.Validate()
Me.TBLDIEMDANHBindingSource.EndEdit()
Me.TBLDIEMDANHTableAdapter.Update(Me.DatabaseDataSet.TBLDIEMDANH)[/FONT]
[FONT=&quot]‘Error in line 3, Because it hasn’t Update. So How can I update to database ? [/FONT]

[FONT=&quot]3. [/FONT][FONT=&quot]3. I want, When I add a value to table TBLHocVien then that value add to table TBLDiem, too. Can I use BindingSource.Copy() ?[/FONT]
[FONT=&quot]I need your help. Thank you very much ![/FONT]
 
Back
Top