|
-
Aug 8th, 2012, 12:44 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Copy child bindingsource to datatable
hi, i'm trying to copy a bindingsource (child table) to a datatable. This is what i did:
Code:
Dim _tblWeek1 As New DataTable
_tblWeek1 = CType(TblPrimeraSemanaBindingSource.DataSource.TblPrimeraSemana, DataTable).Copy
For some reason this code works but only for parent tables not for child table.
This is the error i'm getting: Public member 'TblPrimeraSemana' on type 'BindingSource' not found.
Can some help me on this one?
Regards,
2005
-
Aug 8th, 2012, 01:23 PM
#2
Re: Copy child bindingsource to datatable
Try this:
Code:
Dim _tblWeek1 As New DataTable
_tblWeek1 = CType(TblPrimeraSemanaBindingSource.DataSource, DataTable).Copy
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Aug 8th, 2012, 01:43 PM
#3
Thread Starter
Hyperactive Member
Re: Copy child bindingsource to datatable
hi, stanav. thanks
When i do it like that, removing the name of the table after the ".datasource.", i receive the following error:
Unable to cast object of type 'System.Windows.Forms.BindingSource' to type 'System.Data.Datatable'.
And by the way, on the form load i did loaded the data:
Code:
Me.TblPrimeraSemanaTableAdapter.Fill(Me.PPR432RevCDataSet.tblPrimeraSemana)
Any other idea?
-
Aug 8th, 2012, 01:57 PM
#4
Re: Copy child bindingsource to datatable
Since it's a typed dataset, you have to cast it to its type. However, I'm not sure if you can cast the typed datatable to a generic datatable. That's why I hate those typed dataset/datatable. They are so restricted...
Try this:
Code:
Dim tbl as PPR432RevCDataSet.tblPrimeraSemana = DirectCast(TblPrimeraSemanaBindingSource.DataSource, PPR432RevCDataSet.tblPrimeraSemana).Copy()
'Now, I'm not sure if you can cast tbl to a datatable or not. But you should be able to use tbl as is though
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Aug 9th, 2012, 06:18 AM
#5
Thread Starter
Hyperactive Member
Re: Copy child bindingsource to datatable
Thanks stanav, the previous code didn't worked. But i make it work by doing this:
Code:
_tblWeek1 = PPR432RevCDataSet.Tables("tblPrimeraSemana")
Thanks for the help anyway. Appreciated!
2005
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|