Re: VBScript Problem with Access Query (Unspecified error)
- From: "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 5 Sep 2008 07:51:00 -0500
"Codeblack" <Codeblack@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:7DFA172A-7C37-4098-8CE6-CED7E09DD0E1@xxxxxxxxxxxxxxxx
I am facing a strange problem with a access query. I am trying to retrive
some records from the multiple tables using Inner Join. The query is
working
absolutely fine when i execute the query in MS access 2003. But when i use
the below Query in VBscript then i am getting the below Error. Can any one
help me to findout what is that i am missing. Any help will be greatly
appreciated.
Error : (null): Unspecified error.
Error is pointing at :- Set rs = conn.Execute(StrSQL)
Set conn = CreateObject("ADODB.Connection")
strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=z:\Project\test.mdb"
conn.Open strConnect
intRow = 1
StrSQL = "SELECT [Webmail Domains].[Root Domain],
Sum([Total_Bytes]/1024/1024) AS [Total MB], Sum(SenderToDom.Recip_Counts)
AS
[Recip Counts]"&_"FROM [DeptCode CorpSvcs] INNER JOIN ((SenderToDom INNER
JOIN AllEmployees ON SenderToDom.Sender = AllEmployees.Email) INNER JOIN
[Webmail Domains] ON SenderToDom.Recip_Domain = [Webmail Domains].Domain)
ON
[DeptCode CorpSvcs].DeptCode = AllEmployees.DeptCode"&_
"GROUP BY [Webmail Domains].[Root Domain] ORDER BY
Sum([Total_Bytes]/1024/1024) DESC"
Set rs = conn.Execute(StrSQL)
do While not rs.EOF
wscript.Echo rs(0)
wscript.Echo rs(1)
rs.MoveNext
Loop
RS.Close
set RS = nothing
conn.close
set conn = nothing
Word wrapping makes it very difficult to read your code, but I believe you
need spaces around your "&" (concatenation) and "_" (line continuation)
characters. The string "&_" will definitely fail. It should be " & _". I
would use something similar to:
==========
StrSQL = "SELECT [Webmail Domains].[Root Domain], " _
& "Sum([Total_Bytes]/1024/1024) AS [Total MB], " _
& "Sum(SenderToDom.Recip_Counts) AS [Recip Counts]" _
& "FROM [DeptCode CorpSvcs] " _
& "INNER JOIN ((SenderToDom " _
& "INNER JOIN AllEmployees " _
& "ON SenderToDom.Sender = AllEmployees.Email) " _
& "INNER JOIN [Webmail Domains] " _
& "ON SenderToDom.Recip_Domain = [Webmail Domains].Domain) "
_
& "ON [DeptCode CorpSvcs].DeptCode = AllEmployees.DeptCode" _
& "GROUP BY [Webmail Domains].[Root Domain] " _
& "ORDER BY Sum([Total_Bytes]/1024/1024) DESC"
========
I wasn't sure how I wanted to indent the nested joins to make it easy to
read. The parentheses are important for indicating which JOIN the ON clauses
apply to. However, I believe just adding the spaces should fix the error.
--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--
.
- Follow-Ups:
- Re: VBScript Problem with Access Query (Unspecified error)
- From: Codeblack
- Re: VBScript Problem with Access Query (Unspecified error)
- References:
- VBScript Problem with Access Query (Unspecified error)
- From: Codeblack
- VBScript Problem with Access Query (Unspecified error)
- Prev by Date: Re: Retrieve information of a remote machine in vbscript
- Next by Date: Re: VBScript Problem with Access Query (Unspecified error)
- Previous by thread: VBScript Problem with Access Query (Unspecified error)
- Next by thread: Re: VBScript Problem with Access Query (Unspecified error)
- Index(es):
Relevant Pages
|