By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,647 Members | 1,124 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,647 IT Pros & Developers. It's quick & easy.

Too few parameters. Expected 1.

P: n/a
I have read what this error means, you have invalid column names from the
select statement, misspelling etc.

Here is an excerpt from both my pages, not sure why I am getting this error
still.

----------------------------------------------------------------------------
-
strsql = "select * from Printers where PrinterName <> 'N/A'"

Set Conn = Server.CreateObject("ADODB.Connection")
DSNtest="DRIVER={Microsoft Access Driver (*.mdb)}; "
DSNtest=dsntest & "DBQ=" & Server.MapPath("/database/sa inventory.mdb")
Conn.Open DSNtest

Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strsql, conn, 3,3

----------------------------------------------------------------------------
-
I then send this data to the npResults2 page

response.write "<TD BORDER=1 ALIGN=CENTER WIDTH=50>" & vbcrlf
response.write "<A target='myNewWin' HREF='npResults2.asp?pn=" &
rs("PrinterName")& "'>Edit</a>"
response.write "</TD>" & vbcrlf
----------------------------------------------------------------------------
-

iSerial = Request.QueryString("pn")

strSQL = "SELECT * FROM printers WHERE PrinterName=" & iSerial & ";"

Set Conn = Server.CreateObject("ADODB.Connection")
DSNtest="DRIVER={Microsoft Access Driver (*.mdb)}; "
DSNtest=dsntest & "DBQ=" & Server.MapPath("/database/sa inventory.mdb")
Conn.Open DSNtest

Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strsql, conn, 3,3
Any help is much appreciated.

Jul 21 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
DVan wrote:
I have read what this error means, you have invalid column names from
the select statement, misspelling etc.

Here is an excerpt from both my pages, not sure why I am getting this
error still.

-------------------------------------------------------------------------- -- -
strsql = "select * from Printers where PrinterName <> 'N/A'"
Does this sql statement run without error when you test it using the Access
Query Builder?

Set Conn = Server.CreateObject("ADODB.Connection")
DSNtest="DRIVER={Microsoft Access Driver (*.mdb)}; "
http://www.aspfaq.com/show.asp?id=2126
DSNtest=dsntest & "DBQ=" & Server.MapPath("/database/sa
inventory.mdb")


Does

Response.Write Server.MapPath("/database/sa inventory.mdb")

display the correct path to your database?

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 21 '05 #2

P: n/a
Yes to both questions, I have the same script that works on another page.
I can't figure it out.
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:em**************@TK2MSFTNGP09.phx.gbl...
DVan wrote:
I have read what this error means, you have invalid column names from
the select statement, misspelling etc.

Here is an excerpt from both my pages, not sure why I am getting this
error still.

--------------------------------------------------------------------------
--
-
strsql = "select * from Printers where PrinterName <> 'N/A'"


Does this sql statement run without error when you test it using the

Access Query Builder?

Set Conn = Server.CreateObject("ADODB.Connection")
DSNtest="DRIVER={Microsoft Access Driver (*.mdb)}; "


http://www.aspfaq.com/show.asp?id=2126
DSNtest=dsntest & "DBQ=" & Server.MapPath("/database/sa
inventory.mdb")


Does

Response.Write Server.MapPath("/database/sa inventory.mdb")

display the correct path to your database?

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Jul 21 '05 #3

P: n/a


Is PrinterName a text-based column type? If so, you need to delimit the
data with ' characters.

Function sIn(s)
sIn = "'" & Replace(s, "'", "''") & "'"
End Function

sSQL = "SELECT * FROM Printers WHERE PrinterName = sIn(iSerial)

Ray at work

"DVan" <dt*******@yahoo.com> wrote in message
news:Op**************@TK2MSFTNGP12.phx.gbl...
Yes to both questions, I have the same script that works on another page.
I can't figure it out.
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:em**************@TK2MSFTNGP09.phx.gbl...
DVan wrote:
> I have read what this error means, you have invalid column names from
> the select statement, misspelling etc.
>
> Here is an excerpt from both my pages, not sure wh

Jul 21 '05 #4

P: n/a
Hi Ray,

I added this to my webpage

<SCRIPT LANGUAGE="JavaScript">
Function sIn(s)
sIn = "'" & Replace(s, "'", "''") & "'"
End Function
</SCRIPT>
Then changed the strSQL to

strSQL = "SELECT * FROM Printers WHERE PrinterName = sIn(iSerial)"
and it is still giving me the same error on this line

rs.Open strsql, conn, 3,3

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:%2****************@TK2MSFTNGP14.phx.gbl...


Is PrinterName a text-based column type? If so, you need to delimit the
data with ' characters.

Function sIn(s)
sIn = "'" & Replace(s, "'", "''") & "'"
End Function

sSQL = "SELECT * FROM Printers WHERE PrinterName = sIn(iSerial)

Ray at work

"DVan" <dt*******@yahoo.com> wrote in message
news:Op**************@TK2MSFTNGP12.phx.gbl...
Yes to both questions, I have the same script that works on another page. I can't figure it out.
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:em**************@TK2MSFTNGP09.phx.gbl...
DVan wrote:
> I have read what this error means, you have invalid column names from
> the select statement, misspelling etc.
>
> Here is an excerpt from both my pages, not sure wh


Jul 21 '05 #5

P: n/a
I did not realize you had two sql statements. Which one is raising the
error? The one where you concatenate the iSerial value in? If so, see below:

DVan wrote:
I have read what this error means, you have invalid column names from
the select statement, misspelling etc.

Here is an excerpt from both my pages, not sure why I am getting this
error still.

-------------------------------------------------------------------------- -- -
strsql = "select * from Printers where PrinterName <> 'N/A'"

Set Conn = Server.CreateObject("ADODB.Connection")
DSNtest="DRIVER={Microsoft Access Driver (*.mdb)}; "
DSNtest=dsntest & "DBQ=" & Server.MapPath("/database/sa
inventory.mdb") Conn.Open DSNtest

Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strsql, conn, 3,3
Does this line raise an error?


-------------------------------------------------------------------------- -- -
I then send this data to the npResults2 page

response.write "<TD BORDER=1 ALIGN=CENTER WIDTH=50>" & vbcrlf
response.write "<A target='myNewWin' HREF='npResults2.asp?pn=" &
rs("PrinterName")& "'>Edit</a>"
response.write "</TD>" & vbcrlf
-------------------------------------------------------------------------- -- -

iSerial = Request.QueryString("pn")

strSQL = "SELECT * FROM printers WHERE PrinterName=" & iSerial & ";"


Do

Response.Write strSQL

Try to run the sql statement that appears in the browser window using the
Access Query Builder. I think you'll see what the error is, especially if
you compare it to the earlier sql statement that works.

Here is some advice that will help you avoid this error in the future:
http://www.google.com/groups?hl=en&l...TNGP12.phx.gbl

http://www.google.com/groups?hl=en&l...miter%2Bauthor
:Bob%2Bauthor:Barrows%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26start%3D
10%26sa%3DN

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 21 '05 #6

P: n/a
Yes, that one.

I added this per Ray, but still the same problem

I added this to my webpage

<SCRIPT LANGUAGE="JavaScript">
Function sIn(s)
sIn = "'" & Replace(s, "'", "''") & "'"
End Function
</SCRIPT>
Then changed the strSQL to

strSQL = "SELECT * FROM Printers WHERE PrinterName = sIn(iSerial)"
and it is still giving me the same error on this line

rs.Open strsql, conn, 3,3

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:eQ*************@TK2MSFTNGP15.phx.gbl...
I did not realize you had two sql statements. Which one is raising the
error? The one where you concatenate the iSerial value in? If so, see below:
DVan wrote:
I have read what this error means, you have invalid column names from
the select statement, misspelling etc.

Here is an excerpt from both my pages, not sure why I am getting this
error still.

--------------------------------------------------------------------------
--
-
strsql = "select * from Printers where PrinterName <> 'N/A'"

Set Conn = Server.CreateObject("ADODB.Connection")
DSNtest="DRIVER={Microsoft Access Driver (*.mdb)}; "
DSNtest=dsntest & "DBQ=" & Server.MapPath("/database/sa
inventory.mdb") Conn.Open DSNtest

Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strsql, conn, 3,3


Does this line raise an error?



--------------------------------------------------------------------------
--
-
I then send this data to the npResults2 page

response.write "<TD BORDER=1 ALIGN=CENTER WIDTH=50>" & vbcrlf
response.write "<A target='myNewWin' HREF='npResults2.asp?pn=" &
rs("PrinterName")& "'>Edit</a>"
response.write "</TD>" & vbcrlf


--------------------------------------------------------------------------
--
-

iSerial = Request.QueryString("pn")

strSQL = "SELECT * FROM printers WHERE PrinterName=" & iSerial & ";"


Do

Response.Write strSQL

Try to run the sql statement that appears in the browser window using the
Access Query Builder. I think you'll see what the error is, especially if
you compare it to the earlier sql statement that works.

Here is some advice that will help you avoid this error in the future:

http://www.google.com/groups?hl=en&l...TNGP12.phx.gbl
http://www.google.com/groups?hl=en&l...miter%2Bauthor :Bob%2Bauthor:Barrows%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26start%3D 10%26sa%3DN

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Jul 21 '05 #7

P: n/a
DVan wrote:
Yes, that one.

I added this per Ray, but still the same problem

I added this to my webpage

<SCRIPT LANGUAGE="JavaScript">
Function sIn(s)
sIn = "'" & Replace(s, "'", "''") & "'"
End Function
</SCRIPT>
Then changed the strSQL to

strSQL = "SELECT * FROM Printers WHERE PrinterName = sIn(iSerial)"

I repeat: Response.Write it and attempt to run the resulting statement from
the browser window in Access.

You'll see the problem (I hope). You cannot debug a sql statement without
knowing what it is. Knowing what the vbscript code that's supposed to
generate it looks like will not help. You need to look at the resulting
statement.
Hint: Does your Printers table contain a field called "sIn(iSerial)"?

Please consider using saved parameter queries as explained in the links in
my previous message.

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 21 '05 #8

P: n/a
OK. Thanks, I will give it a try.

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:u4**************@TK2MSFTNGP14.phx.gbl...
DVan wrote:
Yes, that one.

I added this per Ray, but still the same problem

I added this to my webpage

<SCRIPT LANGUAGE="JavaScript">
Function sIn(s)
sIn = "'" & Replace(s, "'", "''") & "'"
End Function
</SCRIPT>
Then changed the strSQL to

strSQL = "SELECT * FROM Printers WHERE PrinterName = sIn(iSerial)"

I repeat: Response.Write it and attempt to run the resulting statement

from the browser window in Access.

You'll see the problem (I hope). You cannot debug a sql statement without
knowing what it is. Knowing what the vbscript code that's supposed to
generate it looks like will not help. You need to look at the resulting
statement.
Hint: Does your Printers table contain a field called "sIn(iSerial)"?

Please consider using saved parameter queries as explained in the links in
my previous message.

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Jul 21 '05 #9

P: n/a
Your function is in client side code. And you STILL haven't delimited the
printername correctly. The SQL statement is looking for exactly what you
typed, a printername value of "sln(iSerial)" without the quotes ...

Have you tried Response.Write strSQL as others have suggested, instead of
just scratching your head over the error?

<%
' ... populate iSerial up here, I assume, from who knows what ...

function sln(s)
sln = "'" & replace(s, "'", "''") & "'"
end function

strSQL = "SELECT * FROM Printers WHERE PrinterName = " & sln(iSerial)
response.write strSQL
response.end
%>

And name your columns, instead of using SELECT *.

--
http://www.aspfaq.com/
(Reverse address to reply.)


"DVan" <dt*******@yahoo.com> wrote in message
news:#B*************@tk2msftngp13.phx.gbl...
Hi Ray,

I added this to my webpage

<SCRIPT LANGUAGE="JavaScript">
Function sIn(s)
sIn = "'" & Replace(s, "'", "''") & "'"
End Function
</SCRIPT>
Then changed the strSQL to

strSQL = "SELECT * FROM Printers WHERE PrinterName = sIn(iSerial)"
and it is still giving me the same error on this line

rs.Open strsql, conn, 3,3

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:%2****************@TK2MSFTNGP14.phx.gbl...


Is PrinterName a text-based column type? If so, you need to delimit the
data with ' characters.

Function sIn(s)
sIn = "'" & Replace(s, "'", "''") & "'"
End Function

sSQL = "SELECT * FROM Printers WHERE PrinterName = sIn(iSerial)

Ray at work

"DVan" <dt*******@yahoo.com> wrote in message
news:Op**************@TK2MSFTNGP12.phx.gbl...
Yes to both questions, I have the same script that works on another page. I can't figure it out.
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:em**************@TK2MSFTNGP09.phx.gbl...
> DVan wrote:
> > I have read what this error means, you have invalid column names from> > the select statement, misspelling etc.
> >
> > Here is an excerpt from both my pages, not sure wh



Jul 21 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.