473,472 Members | 2,163 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 2939
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
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
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
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
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
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
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
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
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
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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
muto222
php
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.