473,490 Members | 2,487 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Too few parameters. Expected 1.

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
9 2940
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
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


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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
3000
by: Andrew Thompson | last post by:
I have written a few scripts to parse the URL arguments and either list them or allow access to the value of any parameter by name. <http://www.physci.org/test/003url/index.html>...
7
9466
by: Dee | last post by:
Running an AfterUpdate event procedure, I get the following error: "Too few parameters. Expected 1." My code is as follows: Private Sub DealerID_AfterUpdate() Dim db As DAO.Database
8
11199
by: RC | last post by:
In my Access 2002 form, I have a combo box and on the AfterUpdate event I use DoCmd.RunSQL ("UPDATE .... to update records in a table. When it starts to run I get a message "You are about to...
1
2873
by: bonnie.tangyn | last post by:
Hello all I get Too few parameters expected 2 error and "The MS Jet Database engine cannot find the input table or query "myTempTablename". Make sure it exists and that its name is spelled...
2
6652
by: Patrick Olurotimi Ige | last post by:
I converted the code below from VB.NET to C# cos i have to add it to a C# application!! But i'm getting the error:- System.Data.SqlClient.SqlCommand.Parameters' denotes a 'property' where a...
14
3241
by: cody | last post by:
I got a similar idea a couple of months ago, but now this one will require no change to the clr, is relatively easy to implement and would be a great addition to C# 3.0 :) so here we go.. To...
1
22281
by: Richard Hollenbeck | last post by:
I wonder what I'm missing? I really feel like a retard because I've been screwing with some code for a very long time. I just must be missing something very simple. In the following example,...
4
10664
by: HeislerKurt | last post by:
I'm getting the infamous error, "Too few parameters. Expected 2", when executing an update SQL statement in VBA. I assume it's a SQL syntax issue, but I can't find the problem, and I used a VBA...
1
3543
by: TheGuyKnownAsY | last post by:
Hi everyone, I'm new here. My problem: the parameters that appear after rs.open when oppening the SQL connection. Microsoft OLE DB Provider for ODBC Drivers error '80040e10' Too few...
5
19107
by: mnarewec | last post by:
Hi folks, I want to create a procedure where by it will take a sqlcommand, a string, and property. I want to use this procedure to add parameters to my sql command of type stored procedures since I...
0
7183
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6852
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7356
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5448
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4878
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3074
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1389
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
628
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.