new problem hooking up to datatable rowchanged event

B

Bernie Yaeger

In one form I have not trouble hooking up to a datatable rowchanged event,
so that I can display fill method progress in a progressbar. But in
another - everything appears the same - I get 'object reference not set to
an instance of an object' (dt is the offending object) from this code:
Me.SqlDataAdapter1.SelectCommand = Me.SqlSelectCommand1

Me.SqlSelectCommand1.CommandText = "SELECT bipad, issuecode, imcacct, title,
brname, ponumber, draw, sold, preturn, r" & _

"return, shortage, net, efficiency, billed, shipdt, uprice, ptype,
posstatus, vflag FROM hi" & _

"std WHERE (shipdt >= " & Chr(39) & gl_browsestartdate & Chr(39) & ")"

Me.SqlSelectCommand1.Connection = Me.SqlConnection1

Me.SqlDataAdapter1.Fill(Me.Histdds1)

Dim dt As DataTable

dt = Histdds1.Tables(0)

AddHandler dt.RowChanged, New DataRowChangeEventHandler(AddressOf
DataTableRow_Changed)

pbar.Maximum = dt.GetChanges.Rows.Count

Thanks for any help.

Bernie Yaeger
 
M

Miha Markic

Hi Bernie,

The only thing that I can think of is that Me.Histdds1 and Histdds1 are not
the same instances.
 
B

Bernie Yaeger

Hi Miha,

Nope; the problem is that when it works the dataadapter update method is
firing the rowchanged event; when using the fill method, this event is not
fired.

I'm back to my original question - what event will enable me to track the
fill method?

Thanks for all you help.

Bernie
 
D

David

Hi Miha,

Nope; the problem is that when it works the dataadapter update method is
firing the rowchanged event; when using the fill method, this event is not
fired.

Well, that's hardly related to "Object reference is not set...". Back
in your original code, which line is firing the exception, and what
object is null (Nothing) at that point that's causing the exception?

At first glance...


That's the line that looks suspect to me. Since you just filled the
DataTable, I'd expect GetChanges to return null (Nothing) there.
 
B

Bernie Yaeger

Hi David,

Thanks for your reply.

That line is the problem, for sure; the value is null because it isn't
returned because the rowchanged event never fires on the .fill method.
That's the problem: I want to show progress in a progressbar of the fill
method, but, unlike the update method, it doesn't fire the rowchanged event,
so I can't figure out how to do this. What I need is the event that the
fill method does fire, so I can increment and run the progressbar as each
row is filled.

Thanks again,

Bernie
 
D

David

Hi David,

Thanks for your reply.

That line is the problem, for sure; the value is null because it isn't
returned because the rowchanged event never fires on the .fill method.

But if you look at your original code, you haven't added the event
handler until *after* the fill method was called. There's no way an
event handler can catch an event before it's bound to the event. If you
want some kind of progress bar, you need to bind the datatable event
before the fill.

That's the problem: I want to show progress in a progressbar of the fill
method, but, unlike the update method, it doesn't fire the rowchanged event,

Actually, the RowChanged event does fire on a fill.

so I can't figure out how to do this. What I need is the event that the
fill method does fire, so I can increment and run the progressbar as each
row is filled.

Of course, this has nothing to do with the fact that a GetChanges call
on a newly-filled datatable is going to return null, which is the
original problem in your first post.
 
B

Bernie Yaeger

Hi David,

Good God, you right! I thought I had placed the fill method above and below
in various tests, but evidently not. Tx so much!

Bernie
 

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