Solved

ASP VBScript SQL SELECT query

Posted on 2013-05-14
9
618 Views
Last Modified: 2013-05-16
ASP VBScript
MS Access

Hello, all.

I have, what I thought was, a simple SELECT statement that works just fine inside of MS Access; however, it is not working when I paste it into my ASP script.

Here is the statement inside Access:
=====
select * from cp_parts where cp_image is not null and cp_image <>""""
=====

Here it is inside my ASP script/connection area:
=====
<%

OpenDb()
Set objRs=Server.CreateObject("ADODB.RecordSet")

strsql="select * from cp_parts where cp_image is not null and cp_image <>"""" "
objRs.Open strsql, objConn, 0, 1, 1
%>
=====


I simply pasted it inside the quotes and it give me a message that it is "... expecting 1 or more parameters...".

What am I doing wrong?


Thank you!
Shane
0
Comment
Question by:lshane
9 Comments
 
LVL 32

Expert Comment

by:Big Monty
ID: 39166260
there looks to be an extra space in the sql, was that just a typo?

strsql="select * from cp_parts where cp_image is not null and cp_image <>"""" "
                                                                                                                            ^
0
 

Author Comment

by:lshane
ID: 39166318
No, there is just a single space there.

Here is the actual message I get when I run the page:
=====
Microsoft OLE DB Provider for ODBC Drivers error '80040e10'

[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.

/pmcct2/copyimages.asp, line 11
=====

Line 11 is this line:  objRs.Open strsql, objConn, 0, 1, 1


It works fine if I just leave it as:  select * from cp_parts where cp_image is not null

... but... there are other fields that are blank, but considered "empty", I guess.  (Something to do with Access)... thus the "AND" portion of it.


Like I said - it runs fine inside of Access.
Doesn't seem to be translating outside of Access.
0
 
LVL 32

Expert Comment

by:Big Monty
ID: 39166364
did you try putting brackets around the field names?
0
 

Author Comment

by:lshane
ID: 39166425
Just tried that... same problem.  No effect.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 40

Expert Comment

by:Sharath
ID: 39166644
Did you try this?

strsql="select * from cp_parts where cp_image is not null and cp_image <>'' "
0
 

Author Comment

by:lshane
ID: 39168055
Hi, Sharath.

Bummer - no go, either.

I have no idea what the deal could be.
0
 
LVL 32

Expert Comment

by:Big Monty
ID: 39168274
let's try another approach, as what you have looks like it should work...

try this:

strsql="select * from cp_parts where cp_image is not null and Len( [cp_image] & """" ) = 0"
0
 
LVL 82

Accepted Solution

by:
hielo earned 500 total points
ID: 39171758
Try:
strsql="select * from cp_parts where (cp_image is not null) and (cp_image <>'') "

Open in new window

0
 

Author Closing Comment

by:lshane
ID: 39172207
Hi, hielo.

Yours seemed to do the trick.


Thanks!
Shane
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Translate a cURL request to Classic ASP 4 418
Classic ASP - cannot get to correct path 17 67
Can not run ASP pages Windows 10 Edge browser. 5 75
SQL Filter Question 8 79
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now