We help IT Professionals succeed at work.
Get Started

Select statement works in SQL Query, not in VBscript.  Why?

754 Views
Last Modified: 2012-05-09
The f ollowing select statement in SQL Query works correctly.  

Select ePO4_CWEPOCON.dbo.OrionUsers.id as 'UserID',ePO4_CWEPOCON.dbo.OrionUsers.Fullname as 'FullName',ePO4_CWEPOCON.dbo.OrionGroups.Name as
'GroupName',Max(ePO4_CWEPOCON.dbo.OrionAuditLog.StartTime) as 'LastLogin' from ePO4_CWEPOCON.dbo.OrionUsers
Left Outer join ePO4_CWEPOCON.dbo.OrionGroupMemberships on ePO4_CWEPOCON.dbo.OrionUsers.ID=ePO4_CWEPOCON.dbo.OrionGroupMemberships.UserID  
Left Outer join ePO4_CWEPOCON.dbo.OrionGroups on ePO4_CWEPOCON.dbo.OrionGroupMemberships.GroupID=ePO4_CWEPOCON.dbo.OrionGroups.ID
Left Outer join ePO4_CWEPOCON.dbo.OrionAuditLog on ePO4_CWEPOCON.dbo.OrionUsers.id=ePO4_CWEPOCON.dbo.OrionAuditLog.UserID group by ePO4_CWEPOCON.dbo.OrionGroups.Name,ePO4_CWEPOCON.dbo.OrionUsers.id,ePO4_CWEPOCON.dbo.OrionUsers.Fullname

When I run the same select statement in vbscript, it doesn't select any records/

rs.open "Select dbo.OrionUsers.id as 'UserID',dbo.OrionUsers.Fullname as 'FullName',dbo.OrionGroups.Name as 'GroupName', Max(dbo.OrionAuditLog.StartTime) as 'LastLogin' from dbo.OrionUsers Left Outer join dbo.OrionGroupMemberships on dbo.OrionUsers.ID=dbo.OrionGroupMemberships.UserID Left Outer join dbo.OrionGroups on dbo.OrionGroupMemberships.GroupID=dbo.OrionGroups.ID Left Outer join dbo.OrionAuditLog on dbo.OrionUsers.id=dbo.OrionAuditLog.UserID group by dbo.OrionGroups.Name,dbo.OrionUsers.id,dbo.OrionUsers.Fullname", db

What is wrong with this?
Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE