DataRowView Trouble

  • Thread starter Thread starter Roshawn
  • Start date Start date
R

Roshawn

Hi,

I am using a DataRowView object that contains exactly one row. Here's my
code:

Dim dv as New DataView(ds.Tables(0), "City = 'Hammond'", "",
DataViewRowState.CurrentRows)
Dim row as DataRowView = dv(0)

The row contains a column that can contain empty data. How can you tell if
the specified column has data or not?

Thanks,
Roshawn
 
Hi,

You might query base row through Row property
DataRowView.Row[index].IsNull()
or you might compare DataRowView.Item[index] to DBNull.Value or null
 
Hi Roshawn,

Almost the same as Miha and a third variant, with that "Is dbnull.value" you
can as well use the variants from Miha in VB.net.

The reason I add this it is VB style because that is in this case a little
bit else than C#.

If dv(0)("myfield") Is dbnull.value

Cor
 
Thanks for all of your input guys. Sorry that I took so long to respond,
but I actually figured it out myself (using IsDbNull). Yet it's still great
to know the other methods as well.

Roshawn
 
Hi,

Sorry for the double post, but I just have to ask this. Which of these
methods is the fastest?

1. DataRowView.Row(index).IsNull( )
2. Compare DataRowView.Item(index) to DBNull.Value or Null
3. IsDBNull(DataRowView.Item(index))

Not that it matters to me, but it could be that one of these methods has a
performance benefit in an ASP.NET application.

Thanks again
Roshawn
 
Miha,

You are right and now I remember me that we both wrote that we did not use
that, did you remember that too?

:-)

Cor
 
Hi Roshawn,

I answered Miha first in this thread.

In the thread where we made that statement that we both not use IsDbNull
Miha stated that IsDBnull would be slower than the other ones.

I asked to him there if he knew how much reading would be needed to show
that when there was reading involved (what was in that thread) and the
answer from Miha was; "Infinity".

What is the same as my idea. And because it is ASP.Net even longer.
:-)
(I know that that is impossible)

Take what you want however, inVBNet I think is what I wrote is the most
standard because it is more or less equal to VBNet style testing to Nothing.
(And is not the same as the IsDbNull function)

That was by the way the only reason I showed it.

I hope this gives some idea's?

Cor
 
Back
Top