October 7th, 2004, 12:37 PM
|
#1 (permalink)
| | Real gangstas sip on Yacc
Join Date: Oct 2001 Location: Suckas-ville
Posts: 4,549
| VBScript SQL Limitations?
I hate this language more and more everyday
That being said, I have two queries that work just fine in MS SQL query analyzer. Then I plug the query into VBScript, it returns nothing. No error is thrown, I am just greeted with an emplty record set.
If I have it print the SQL right before it executes it and plug that into MS Query Analyzer manually I get the desired results. Not in the program though.
SQL statement. Code: Select Count(*) From PDA_SMS_Users where Not exists (Select * from Users Where PDA_SMS_Users.username = Users.username AND ((([Access] - ([Access] % 4)) % (4*2))= 4 OR (([Access] - ([Access] % 8)) % (8*2)) = 8)) Relevent code: Code: sSQL2 = "Select Count(*) From PDA_SMS_Users where Not exists (Select * from Users Where PDA_SMS_Users.username = Users.username AND ((([Access] - ([Access] % 4)) % (4*2))= 4 OR (([Access] - ([Access] % 8)) % (8*2)) = 8))"
Set oRS = oConn.execute(sSQL2)
iRecordCount = oRS(0) iRecordCount comes up at 0 in the VBscript program and the correct number in MS Query analyzer
Jkrohn
Last edited by jkrohn : October 7th, 2004 at 12:40 PM.
|
| |
October 7th, 2004, 12:51 PM
|
#2 (permalink)
| | Ultimate Member
Join Date: Oct 2001
Posts: 21,026
|
ah yes I hate that problem as well
Check into the ado connection properties, I can't remember which one it is
adoRecordset.CursorLocation = adUseServer
adoRecordset.CursorType = adOpenStatic
Check the value of those two constants on this site http://asp.programmershelp.co.uk/adoconstants.php |
| |
October 7th, 2004, 12:52 PM
|
#3 (permalink)
| | Kawaru wa yo!
Join Date: Oct 2001 Location: Kingsford, MI
Posts: 16,137
|
Nevermind, listen to Vass.
I never got cursorlocation right. I hate SQL. |
| |
October 7th, 2004, 02:17 PM
|
#4 (permalink)
| | Real gangstas sip on Yacc
Join Date: Oct 2001 Location: Suckas-ville
Posts: 4,549
|
God I am getting pissed.
Unfortunately that didn't work Vass.
I converted it all to oRS.open and such, but it still will not return correctly.
Even a simple statement like Select Count(*) From table results in zero :-/
What angers me more is I have the exact same page (and code copied this page from that one) only with a modified SQL statement (one less condition) and it all works perfectly.
I can't even get that page to load ANY data no matter the query.
Jkrohn |
| |
October 7th, 2004, 02:19 PM
|
#5 (permalink)
| | Kawaru wa yo!
Join Date: Oct 2001 Location: Kingsford, MI
Posts: 16,137
|
Could it be a simple field name misspelling?  |
| |
October 7th, 2004, 02:27 PM
|
#6 (permalink)
| | Real gangstas sip on Yacc
Join Date: Oct 2001 Location: Suckas-ville
Posts: 4,549
|
Bah, gimme a minute on this one
Jkrohn |
| |
October 7th, 2004, 02:39 PM
|
#7 (permalink)
| | Real gangstas sip on Yacc
Join Date: Oct 2001 Location: Suckas-ville
Posts: 4,549
|
Ok, I wish it was a field misspelling :-/ Remember, these queries work EXACTLY as they are suppossed to in MS Query analyzer.
Have a look for yourself.
One that works Code: "Select PDA_SMS_Users.Username, PDA_SMS_Users.pnumber, PDA_SMS_Users.provider, PDA_SMS_Users.LME" & sMetal & "C, PDA_SMS_Users.LME" & sMetal & "WT From PDA_SMS_Users,Users WHERE PDA_SMS_Users.username = Users.username AND PDA_SMS_Users.LME" & sMetal & " LIKE " & "'%" & sTime & "%' AND SubscriptionEndDate > GETDATE() AND (([Access] - ([Access] % 4)) % (4*2)) = 4" One that doesn't: Code: "Select PDA_SMS_Users.Username, PDA_SMS_Users.pnumber, PDA_SMS_Users.provider, PDA_SMS_Users.LME" & sMetal & "C, PDA_SMS_Users.LME" & sMetal & "WT From PDA_SMS_Users,Users WHERE PDA_SMS_Users.username = Users.username AND PDA_SMS_Users.LME" & sMetal & " LIKE " & "'%" & sTime & "%' AND SubscriptionEndDate > GETDATE() AND Users.Access = 2" And for the second query.
One that does work: Code: "Select Count(*) From PDA_SMS_Users,Users WHERE PDA_SMS_Users.username = Users.username AND SubscriptionEndDate > GETDATE() AND PDA_SMS_Users.LME" & sMetal & " LIKE " & "'%" & sTime & "%' AND (([Access] - ([Access] % 4)) % (4*2)) = 4 " Code: "Select Count(*) From PDA_SMS_Users,Users where PDA_SMS_Users.Username = Users.username AND SubscriptionEndDate > GETDATE() AND PDA_SMS_Users.LME" & sMetal & " LIKE " & "'%" & sTime & "%' AND Users.Access = 2" The only differences between the two come at the end. If I plug the two that don't work into the page that does, they still don't work. Reverting to the originals causes the page to behave as it should though. Remember that these do EXACTLY what I want in MS Query Analyzer.
Thank god it is lunch, I am going to kill someone. I need a break.
Jkrohn |
| |
October 7th, 2004, 04:11 PM
|
#8 (permalink)
| | Real gangstas sip on Yacc
Join Date: Oct 2001 Location: Suckas-ville
Posts: 4,549
|
Well it is now working. NO idea what the hell happened.
Thats three hours down the drain.
/me sighs
Jkrohn |
| | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | |
Posting Rules
| You may post new threads You may post replies You may not post attachments You may not edit your posts HTML code is Off | | | | Most Active Discussions | | | | | Recent Discussions  | | | | | |