Checking for Empty Dataset -- Simple Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ron

    #1

    Checking for Empty Dataset -- Simple Question

    Can anyone tell me how to check and see if a dataset is empty?

    I am writing a search function that returns a dataset and binds it to a
    datagrid. If no data is found, I would like to make the grid invisible and
    have a label appear stating that no data was found.

    Any suggestions?

    Thanks,

    Ron Rodenberg


  • Steve C. Orr, MCSD

    #2
    Re: Checking for Empty Dataset -- Simple Question

    If MyDataSet.Table s.Count = 0 Then 'it's empty

    --
    I hope this helps,
    Steve C. Orr, MCSD




    "Ron" <ron@razorvisio n.net> wrote in message
    news:bekevp$1i5 @library1.airne ws.net...[color=blue]
    > Can anyone tell me how to check and see if a dataset is empty?
    >
    > I am writing a search function that returns a dataset and binds it to a
    > datagrid. If no data is found, I would like to make the grid invisible and
    > have a label appear stating that no data was found.
    >
    > Any suggestions?
    >
    > Thanks,
    >
    > Ron Rodenberg
    >
    >[/color]


    Comment

    • Ron

      #3
      Re: Checking for Empty Dataset -- Simple Question

      Thanks a lot Gaston, I appreciate your help.


      "GastonQ" <gastonq_nospam @yahoo.com.ar> wrote in message
      news:04ba01c347 1c$dca7d9b0$a10 1280a@phx.gbl.. .[color=blue]
      > Hi Ron, to check an empty DataSet you must verify the Rows
      > of the DataTable object that contains the database query
      > result.
      >
      > For example:
      > DataSet ds = new DataSet( "MyTable" );
      > ...
      > if( ds.Tables[ "MyTable" ].Rows.Count == 0 )
      > // No records
      > else
      > // Do something...
      >
      > Regards
      > Gaston Quirque
      > Microsoft MVP
      >[color=green]
      > >-----Original Message-----
      > >Can anyone tell me how to check and see if a dataset is[/color]
      > empty?[color=green]
      > >
      > >I am writing a search function that returns a dataset and[/color]
      > binds it to a[color=green]
      > >datagrid. If no data is found, I would like to make the[/color]
      > grid invisible and[color=green]
      > >have a label appear stating that no data was found.
      > >
      > >Any suggestions?
      > >
      > >Thanks,
      > >
      > >Ron Rodenberg
      > >
      > >
      > >.
      > >[/color][/color]


      Comment

      Working...