empty dataset returned

From: kellydotnetnewbie (kelly.heinz_at_co.macomb.mi.us)
Date: 10/30/03


Date: 30 Oct 2003 07:24:12 -0800

Using Visual Studio.Net, Asp.Net, VB.Net:
I'm doing a search of datasets to see if a client alrady exists before
making a new entry. The problem is, if a match doesn't exist I
receive an error "System.IndexOutOfRangeException". How can I check
for the empty dataset and allow the process to continue without
generating an error? Here is my code:

daParentSearch.SelectCommand.Parameters("@LastName").Value =
txtLastName.Text
        daParentSearch.SelectCommand.Parameters("@DOB").Value =
txtDOB.Text
        daParentSearch.Fill(DsParentSearch1, "ParentalWaiver")
        Dim tblParent As New DataTable
        tblParent = DsParentSearch1.Tables("ParentalWaiver")
        Dim rowParent As DataRow
        rowParent = DsParentSearch1.Tables(0).Rows(0)
        If "NotFound" Then (What is the proper syntax for this?)
                Response.Redirect("NotFound.aspx")
            Else
                dgParentSearch.Visible = True
                dgParentSearch.DataBind()
            End If
        
    End Sub



Relevant Pages

  • Re: Field validation does not kick in
    ... I only just require to check and increment the if there is another ... I generally use the forms BeforeUpdate event to trap for data entry errors. ... This event fires before the data is actually written, and has a Cancel ... Private Sub Form_BeforeUpdate ...
    (microsoft.public.access.formscoding)
  • Re: Using Validation to force entry into cells?
    ... Uh oh...I run into a problem now with every copy of this worksheet. ... Private Sub Worksheet_Change ... > Option Explicit ... >> entry into this column in our form. ...
    (microsoft.public.excel.misc)
  • Re: Creating a New Record in Sub Form_Current
    ... any attempt to use Form_Current to force the entry of a new record is ... > required to determine whether the first record is already complete. ... > code is run in Sub Form_Open or Sub Form_Load. ... This conditional interlocking generally works well. ...
    (microsoft.public.access.forms)
  • Re: event fire
    ... 'J' is entered Then to subtract 10.00 from entry and copy the entrys in cells ... Private Sub Workbook_SheetChange ... Dim dblValue As Double ... Dim varTargetAmt As Variant ...
    (microsoft.public.excel.programming)
  • Entry.cs // A common EntryPoint for a project.
    ... /// Main Entry Point. ... Public Sub New ... excel workbook, sheet. ... microsoft Excel object lib 9, 10, 11, etc via the Project Add Reference ...
    (microsoft.public.dotnet.languages.csharp)