Generating a dataview from a datatable

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
 
S

Steve Gerrard

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top