Generating a dataview from a datatable

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

I have a strongly typed dataset generated by vs 2008. I am trying to fill in
one of the datatables in the dataset and then cerate a dataview from the
datatable. I have used the below code but it does not work.

Public ds As MyDS
Public dv As DataView
Public daMyTbl As MyDSTableAdapters.MyTblTableAdapter

ds.MyTbl.Clear()
daMyTbl.Fill(ds.MyTbl)

dv = New DataView(ds.MyTbl)

For starters it givbes 'Object reference not set to an instance of an
object.' error on ds.MyTbl.Clear() line. What am I doing wrong?

Many Thanks

Regards
 
John said:
Hi

I have a strongly typed dataset generated by vs 2008. I am trying to
fill in one of the datatables in the dataset and then cerate a
dataview from the datatable. I have used the below code but it does
not work.
Public ds As MyDS
Public dv As DataView
Public daMyTbl As MyDSTableAdapters.MyTblTableAdapter

ds.MyTbl.Clear()
daMyTbl.Fill(ds.MyTbl)

dv = New DataView(ds.MyTbl)

For starters it givbes 'Object reference not set to an instance of an
object.' error on ds.MyTbl.Clear() line. What am I doing wrong?

Many Thanks

Regards

As with any object, you need
ds = New MyDS

You'll probably want one for daMyTbl as well.
 
Back
Top