No records retrived..?

Discussion in 'ASP .Net' started by Kent Johnson, Oct 24, 2003.

  1. Kent Johnson

    Kent Johnson Guest

    Hi all,

    I have the following:
    ==================
    SQLSelect = "SELECT * from MyTable where Field1='" & strVar & "'"

    Dim mySqlDA As New System.Data.SqlClient.SqlDataAdapter(SQLSelect, strConn)
    Dim myDS As New System.Data.DataSet()

    mySqlDA.Fill(myDS)
    ===================
    ...how can I handle the case if no records are retrived from the
    SQL-statement?

    /Kent J.
     
    Kent Johnson, Oct 24, 2003
    #1
    1. Advertising

  2. > ..how can I handle the case if no records are retrived from the
    > SQL-statement?


    What exactly do you mean? If no records are returned, your DataSet will have
    no records in it.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    http://www.takempis.com
    Big Things are made up of
    Lots of Little Things.

    "Kent Johnson" <> wrote in message
    news:7wgmb.34832$...
    > Hi all,
    >
    > I have the following:
    > ==================
    > SQLSelect = "SELECT * from MyTable where Field1='" & strVar & "'"
    >
    > Dim mySqlDA As New System.Data.SqlClient.SqlDataAdapter(SQLSelect,

    strConn)
    > Dim myDS As New System.Data.DataSet()
    >
    > mySqlDA.Fill(myDS)
    > ===================
    > ..how can I handle the case if no records are retrived from the
    > SQL-statement?
    >
    > /Kent J.
    >
    >
    >
     
    Kevin Spencer, Oct 24, 2003
    #2
    1. Advertising

  3. Kent Johnson

    Kent Johnson Guest

    Kevin,
    Yes, that's what I mean.
    I want to check the datset before proceeding.
    Something like:

    If isnull(myDS)=true then
    Label1.Text="'What you asked for doesn't exist!"
    exit sub
    endif

    /Kent J.







    "Kevin Spencer" <> wrote in message
    news:#...
    > > ..how can I handle the case if no records are retrived from the
    > > SQL-statement?

    >
    > What exactly do you mean? If no records are returned, your DataSet will

    have
    > no records in it.
    >
    > --
    > HTH,
    >
    > Kevin Spencer
    > Microsoft MVP
    > .Net Developer
    > http://www.takempis.com
    > Big Things are made up of
    > Lots of Little Things.
    >
    > "Kent Johnson" <> wrote in message
    > news:7wgmb.34832$...
    > > Hi all,
    > >
    > > I have the following:
    > > ==================
    > > SQLSelect = "SELECT * from MyTable where Field1='" & strVar & "'"
    > >
    > > Dim mySqlDA As New System.Data.SqlClient.SqlDataAdapter(SQLSelect,

    > strConn)
    > > Dim myDS As New System.Data.DataSet()
    > >
    > > mySqlDA.Fill(myDS)
    > > ===================
    > > ..how can I handle the case if no records are retrived from the
    > > SQL-statement?
    > >
    > > /Kent J.
    > >
    > >
    > >

    >
    >
     
    Kent Johnson, Oct 25, 2003
    #3
  4. If myDS.Tables(0).Rows.Count = 0 Then...

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    http://www.takempis.com
    Big Things are made up of
    Lots of Little Things.

    "Kent Johnson" <> wrote in message
    news:H3qmb.34877$...
    > Kevin,
    > Yes, that's what I mean.
    > I want to check the datset before proceeding.
    > Something like:
    >
    > If isnull(myDS)=true then
    > Label1.Text="'What you asked for doesn't exist!"
    > exit sub
    > endif
    >
    > /Kent J.
    >
    >
    >
    >
    >
    >
    >
    > "Kevin Spencer" <> wrote in message
    > news:#...
    > > > ..how can I handle the case if no records are retrived from the
    > > > SQL-statement?

    > >
    > > What exactly do you mean? If no records are returned, your DataSet will

    > have
    > > no records in it.
    > >
    > > --
    > > HTH,
    > >
    > > Kevin Spencer
    > > Microsoft MVP
    > > .Net Developer
    > > http://www.takempis.com
    > > Big Things are made up of
    > > Lots of Little Things.
    > >
    > > "Kent Johnson" <> wrote in message
    > > news:7wgmb.34832$...
    > > > Hi all,
    > > >
    > > > I have the following:
    > > > ==================
    > > > SQLSelect = "SELECT * from MyTable where Field1='" & strVar & "'"
    > > >
    > > > Dim mySqlDA As New System.Data.SqlClient.SqlDataAdapter(SQLSelect,

    > > strConn)
    > > > Dim myDS As New System.Data.DataSet()
    > > >
    > > > mySqlDA.Fill(myDS)
    > > > ===================
    > > > ..how can I handle the case if no records are retrived from the
    > > > SQL-statement?
    > > >
    > > > /Kent J.
    > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    Kevin Spencer, Oct 27, 2003
    #4
  5. Kent Johnson

    Alvin Bruney Guest

    I prefer
    if(myDs != null && myDs.Tab....

    since myDS can be null and the call to examine count will blow up. You knew
    that but I wasn't sure others knew it.

    regards

    --


    -----------
    Got TidBits?
    Get it here: www.networkip.net/tidbits
    "Kevin Spencer" <> wrote in message
    news:#...
    > If myDS.Tables(0).Rows.Count = 0 Then...
    >
    > --
    > HTH,
    >
    > Kevin Spencer
    > Microsoft MVP
    > .Net Developer
    > http://www.takempis.com
    > Big Things are made up of
    > Lots of Little Things.
    >
    > "Kent Johnson" <> wrote in message
    > news:H3qmb.34877$...
    > > Kevin,
    > > Yes, that's what I mean.
    > > I want to check the datset before proceeding.
    > > Something like:
    > >
    > > If isnull(myDS)=true then
    > > Label1.Text="'What you asked for doesn't exist!"
    > > exit sub
    > > endif
    > >
    > > /Kent J.
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > > "Kevin Spencer" <> wrote in message
    > > news:#...
    > > > > ..how can I handle the case if no records are retrived from the
    > > > > SQL-statement?
    > > >
    > > > What exactly do you mean? If no records are returned, your DataSet

    will
    > > have
    > > > no records in it.
    > > >
    > > > --
    > > > HTH,
    > > >
    > > > Kevin Spencer
    > > > Microsoft MVP
    > > > .Net Developer
    > > > http://www.takempis.com
    > > > Big Things are made up of
    > > > Lots of Little Things.
    > > >
    > > > "Kent Johnson" <> wrote in message
    > > > news:7wgmb.34832$...
    > > > > Hi all,
    > > > >
    > > > > I have the following:
    > > > > ==================
    > > > > SQLSelect = "SELECT * from MyTable where Field1='" & strVar & "'"
    > > > >
    > > > > Dim mySqlDA As New System.Data.SqlClient.SqlDataAdapter(SQLSelect,
    > > > strConn)
    > > > > Dim myDS As New System.Data.DataSet()
    > > > >
    > > > > mySqlDA.Fill(myDS)
    > > > > ===================
    > > > > ..how can I handle the case if no records are retrived from the
    > > > > SQL-statement?
    > > > >
    > > > > /Kent J.
    > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    Alvin Bruney, Oct 27, 2003
    #5
  6. Kent Johnson

    Kent Johnson Guest

    Kevin,

    Thanks!

    /Kent J.


    "Kevin Spencer" <> wrote in message
    news:#...
    > If myDS.Tables(0).Rows.Count = 0 Then...
    >
    > --
    > HTH,
    >
    > Kevin Spencer
    > Microsoft MVP
    > .Net Developer
    > http://www.takempis.com
    > Big Things are made up of
    > Lots of Little Things.
    >
    > "Kent Johnson" <> wrote in message
    > news:H3qmb.34877$...
    > > Kevin,
    > > Yes, that's what I mean.
    > > I want to check the datset before proceeding.
    > > Something like:
    > >
    > > If isnull(myDS)=true then
    > > Label1.Text="'What you asked for doesn't exist!"
    > > exit sub
    > > endif
    > >
    > > /Kent J.
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > > "Kevin Spencer" <> wrote in message
    > > news:#...
    > > > > ..how can I handle the case if no records are retrived from the
    > > > > SQL-statement?
    > > >
    > > > What exactly do you mean? If no records are returned, your DataSet

    will
    > > have
    > > > no records in it.
    > > >
    > > > --
    > > > HTH,
    > > >
    > > > Kevin Spencer
    > > > Microsoft MVP
    > > > .Net Developer
    > > > http://www.takempis.com
    > > > Big Things are made up of
    > > > Lots of Little Things.
    > > >
    > > > "Kent Johnson" <> wrote in message
    > > > news:7wgmb.34832$...
    > > > > Hi all,
    > > > >
    > > > > I have the following:
    > > > > ==================
    > > > > SQLSelect = "SELECT * from MyTable where Field1='" & strVar & "'"
    > > > >
    > > > > Dim mySqlDA As New System.Data.SqlClient.SqlDataAdapter(SQLSelect,
    > > > strConn)
    > > > > Dim myDS As New System.Data.DataSet()
    > > > >
    > > > > mySqlDA.Fill(myDS)
    > > > > ===================
    > > > > ..how can I handle the case if no records are retrived from the
    > > > > SQL-statement?
    > > > >
    > > > > /Kent J.
    > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    Kent Johnson, Oct 27, 2003
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. CsaaGuy
    Replies:
    3
    Views:
    477
    Brock Allen
    Jul 20, 2005
  2. Luke Airig
    Replies:
    0
    Views:
    823
    Luke Airig
    Dec 31, 2003
  3. SupaJay

    How/Where the OldValuesParameters is retrived from?

    SupaJay, Sep 8, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    176
    SupaJay
    Sep 8, 2006
  4. Dan

    Delete records or update records

    Dan, May 10, 2004, in forum: ASP General
    Replies:
    1
    Views:
    490
    Ray at
    May 10, 2004
  5. Replies:
    3
    Views:
    710
    Anthony Jones
    Nov 2, 2006
Loading...

Share This Page