Same code, inconsistent results -- Please Help!

N

Neo Geshel

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.
************************************************************************
 
K

Kevin Spencer

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.
 
N

Neo Geshel

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.
************************************************************************
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top