Home All Groups Group Topic Archive Search About

error "object refe..."

Author
24 Nov 2006 4:20 AM
touf
Hi,
I've the "object reference not set to an instance of an abject" error in the
folowing code (initialise a datatable's rows to 0)
this is hapening for the 2nd field (taxe) of the 2nd row (the first is ok!!)

DSFrm.Tables("test").DefaultView.RowFilter = True

For k = 0 To DSFrm.Tables("test").DefaultView.Count - 1

    DSFrm.Tables("test").DefaultView(k).Item("price") = 0

    DSFrm.Tables("test").DefaultView(k).Item("taxe") = 0

Next



Any help please???

Author
24 Nov 2006 5:32 AM
Cor Ligthert [MVP]
touf,

Often this kind of trouble happens when the field description ("taxe") is
not in the right case.

Cor

Show quoteHide quote
"touf" <tou***@hotmail.com> schreef in bericht
news:%23qDbT$3DHHA.4312@TK2MSFTNGP06.phx.gbl...
> Hi,
> I've the "object reference not set to an instance of an abject" error in
> the folowing code (initialise a datatable's rows to 0)
> this is hapening for the 2nd field (taxe) of the 2nd row (the first is
> ok!!)
>
> DSFrm.Tables("test").DefaultView.RowFilter = True
>
> For k = 0 To DSFrm.Tables("test").DefaultView.Count - 1
>
>    DSFrm.Tables("test").DefaultView(k).Item("price") = 0
>
>    DSFrm.Tables("test").DefaultView(k).Item("taxe") = 0
>
> Next
>
>
>
> Any help please???
>
>
Author
24 Nov 2006 8:09 AM
Prester John
I suspect, for starters, you need to get rid of the
"DSFrm.Tables("test").DefaultView.RowFilter = True" line.  I don't know what
you intended, but the default for a RowFilter is all rows.

Also, why use the DefaultView at all? It just passes the changes to the
datatable anyway...

In VB, instead of FORTRAN (pseudo code if it doesn't work ;) :

For row as DataRow in DSFrm.Tables("test").Rows
      row.Item("price") = 0
      row.Item("taxe") = 0
Next row

HTH,
Prester John

Show quoteHide quote
"touf" <tou***@hotmail.com> wrote in message
news:%23qDbT$3DHHA.4312@TK2MSFTNGP06.phx.gbl...
> Hi,
> I've the "object reference not set to an instance of an abject" error in
> the folowing code (initialise a datatable's rows to 0)
> this is hapening for the 2nd field (taxe) of the 2nd row (the first is
> ok!!)
>
> DSFrm.Tables("test").DefaultView.RowFilter = True
>
> For k = 0 To DSFrm.Tables("test").DefaultView.Count - 1
>
>    DSFrm.Tables("test").DefaultView(k).Item("price") = 0
>
>    DSFrm.Tables("test").DefaultView(k).Item("taxe") = 0
>
> Next
>
>
>
> Any help please???
>
>