Same code, inconsistent results -- Please Help!

Discussion in 'ASP .Net' started by Neo Geshel, Nov 3, 2003.

  1. Neo Geshel

    Neo Geshel Guest

    I have the two subs:

    Sub UniqueHits()
    Dim StrSQLQuery As String
    Dim ObjAdapter as New OleDbDataAdapter()
    Dim ObjDataSet as DataSet
    StrSQLQuery = "SELECT * FROM Browser WHERE IsUnique = True"
    ObjAdapter.SelectCommand = new OleDbCommand(StrSQLQuery,
    ObjConnection)
    ObjDataSet = new DataSet()
    ObjAdapter.Fill(ObjDataSet,"hits")
    Dim RcdCount as Integer
    RcdCount = ObjDataSet.Tables("hits").Rows.Count.ToString()
    UniqueHitCount.Text = "There have been " & RcdCount & " unique
    visitors to your site."
    End Sub


    Sub TotalHitsGetMetz()
    Dim StrSQLQuery As String
    Dim ObjAdapter as New OleDbDataAdapter()
    Dim ObjDataSet as DataSet
    StrSQLQuery = "SELECT * FROM Browser WHERE Domain = 'domain.com'"
    ObjAdapter.SelectCommand = new OleDbCommand(StrSQLQuery,
    ObjConnection)
    ObjDataSet = new DataSet()
    ObjAdapter.Fill(ObjDataSet,"hits")
    Dim RcdCount as Integer
    RcdCount = ObjDataSet.Tables("hits").Rows.Count.ToString()
    TotalHitCountGetMetz.Text = "GetMetz has been accessed " & RcdCount &
    " times."
    End Sub


    The first one works perfectly. However, the second throws the following
    error message:

    Description: An unhandled exception occurred during the execution of
    the current web request. Please review the stack trace for more
    information about the error and where it originated in the code.

    Exception Details: System.Data.OleDb.OleDbException:
    IErrorInfo.GetDescription failed with E_FAIL(0x80004005).

    Source Error:
    Line 40: ObjAdapter.Fill(ObjDataSet,"hits")



    What gives?? The code between the two are identical. There is no logical
    difference between the two, and yet the second throws the error. I know
    this, because removing the "WHERE Domain = 'domain.com'" makes it work
    again. Problem is, my client uses up to 4 different domain names for his
    web site, and I want to count the hits for each domain name.

    IsUnique is a binary (yes/no) variable in the DB, and Domain is a
    string. This is an Access db. Removing the single quotes from around the
    Domain value makes no difference.

    TIA to everyone that helps this poor sod.
    ....Geshel
    --
    ************************************************************************
    Reply-to e-mail forwards all received e-mails to SpamCop for UBE/UCE
    (Unsolicited Bulk/Commercial E-mail) reporting. DO NOT USE THAT ADDRESS!
    Please send e-mail to my first name at my last name dot org.
    ************************************************************************
    Neo Geshel, Nov 3, 2003
    #1
    1. Advertising

  2. Chances are, "Domain" is a reserved word in Access. I'm not sure, though.
    Try putting square brackets around the table name, as in:

    StrSQLQuery = "SELECT * FROM Browser WHERE [Domain] = 'domain.com'"

    --
    HTH,

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

    "Neo Geshel" <> wrote in message
    news:...
    > I have the two subs:
    >
    > Sub UniqueHits()
    > Dim StrSQLQuery As String
    > Dim ObjAdapter as New OleDbDataAdapter()
    > Dim ObjDataSet as DataSet
    > StrSQLQuery = "SELECT * FROM Browser WHERE IsUnique = True"
    > ObjAdapter.SelectCommand = new OleDbCommand(StrSQLQuery,
    > ObjConnection)
    > ObjDataSet = new DataSet()
    > ObjAdapter.Fill(ObjDataSet,"hits")
    > Dim RcdCount as Integer
    > RcdCount = ObjDataSet.Tables("hits").Rows.Count.ToString()
    > UniqueHitCount.Text = "There have been " & RcdCount & " unique
    > visitors to your site."
    > End Sub
    >
    >
    > Sub TotalHitsGetMetz()
    > Dim StrSQLQuery As String
    > Dim ObjAdapter as New OleDbDataAdapter()
    > Dim ObjDataSet as DataSet
    > StrSQLQuery = "SELECT * FROM Browser WHERE Domain = 'domain.com'"
    > ObjAdapter.SelectCommand = new OleDbCommand(StrSQLQuery,
    > ObjConnection)
    > ObjDataSet = new DataSet()
    > ObjAdapter.Fill(ObjDataSet,"hits")
    > Dim RcdCount as Integer
    > RcdCount = ObjDataSet.Tables("hits").Rows.Count.ToString()
    > TotalHitCountGetMetz.Text = "GetMetz has been accessed " & RcdCount &
    > " times."
    > End Sub
    >
    >
    > The first one works perfectly. However, the second throws the following
    > error message:
    >
    > Description: An unhandled exception occurred during the execution of
    > the current web request. Please review the stack trace for more
    > information about the error and where it originated in the code.
    >
    > Exception Details: System.Data.OleDb.OleDbException:
    > IErrorInfo.GetDescription failed with E_FAIL(0x80004005).
    >
    > Source Error:
    > Line 40: ObjAdapter.Fill(ObjDataSet,"hits")
    >
    >
    >
    > What gives?? The code between the two are identical. There is no logical
    > difference between the two, and yet the second throws the error. I know
    > this, because removing the "WHERE Domain = 'domain.com'" makes it work
    > again. Problem is, my client uses up to 4 different domain names for his
    > web site, and I want to count the hits for each domain name.
    >
    > IsUnique is a binary (yes/no) variable in the DB, and Domain is a
    > string. This is an Access db. Removing the single quotes from around the
    > Domain value makes no difference.
    >
    > TIA to everyone that helps this poor sod.
    > ...Geshel
    > --
    > ************************************************************************
    > Reply-to e-mail forwards all received e-mails to SpamCop for UBE/UCE
    > (Unsolicited Bulk/Commercial E-mail) reporting. DO NOT USE THAT ADDRESS!
    > Please send e-mail to my first name at my last name dot org.
    > ************************************************************************
    Kevin Spencer, Nov 3, 2003
    #2
    1. Advertising

  3. Neo Geshel

    Neo Geshel Guest

    In article <>,
    says...
    > Chances are, "Domain" is a reserved word in Access. I'm not sure, though.
    > Try putting square brackets around the table name, as in:
    >
    > StrSQLQuery = "SELECT * FROM Browser WHERE [Domain] = 'domain.com'"


    Yippeeee!!! That did it!!

    ....Geshel
    --
    ************************************************************************
    Reply-to e-mail forwards all received e-mails to SpamCop for UBE/UCE
    (Unsolicited Bulk/Commercial E-mail) reporting. DO NOT USE THAT ADDRESS!
    Please send e-mail to my first name at my last name dot org.
    ************************************************************************
    Neo Geshel, Nov 3, 2003
    #3
    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. Bryan
    Replies:
    2
    Views:
    305
    Bryan
    Sep 23, 2004
  2. Inconsistent Program Results

    , Mar 6, 2007, in forum: C Programming
    Replies:
    20
    Views:
    627
    Randy Howard
    Mar 18, 2007
  3. gershar
    Replies:
    5
    Views:
    221
    gershar
    Oct 26, 2010
  4. Eric Sosman

    Re: Inconsistent results between char/short/int

    Eric Sosman, Sep 24, 2011, in forum: C Programming
    Replies:
    2
    Views:
    293
    Jorgen Grahn
    Sep 29, 2011
  5. AbeR

    Inconsistent Results from asp

    AbeR, May 18, 2004, in forum: ASP General
    Replies:
    2
    Views:
    175
Loading...

Share This Page