473,378 Members | 1,066 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

SQL Statement Error?!

Oli
Hi,

Im trying to use a sesson statement within an SQL Statement:

sql = "SELECT * FROM tblNumbers WHERE AllocatedTo=" & Session("Company") &
""

And get the error:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
/numberlist.asp, line 31

Anyone got any ideas? Surely this can only be something basic?

TIA
Oli
Jul 19 '05 #1
6 2816
sql = "SELECT * FROM tblNumbers WHERE AllocatedTo=" & Session("Company")

RESPONSE.WRITE SQL
RESPONSE.END

What does that show you?

Ray at work
"Oli" <ol*@NOSPAMoliwoods.co.uk> wrote in message
news:bq**********@sparta.btinternet.com...
Hi,

Im trying to use a sesson statement within an SQL Statement:

sql = "SELECT * FROM tblNumbers WHERE AllocatedTo=" & Session("Company") &
""

And get the error:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
/numberlist.asp, line 31

Anyone got any ideas? Surely this can only be something basic?

TIA
Oli

Jul 19 '05 #2
Oli
SELECT * FROM tblNumbers WHERE AllocatedTo=AlternateMedia

Which is correct! Just noticed that the error is not with that line....
Line 33 is:

rs.Open sql, cn

What does "Expected 1" mean?

Thanks!
Oli

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:em**************@TK2MSFTNGP09.phx.gbl...
sql = "SELECT * FROM tblNumbers WHERE AllocatedTo=" & Session("Company")

RESPONSE.WRITE SQL
RESPONSE.END

What does that show you?

Ray at work
"Oli" <ol*@NOSPAMoliwoods.co.uk> wrote in message
news:bq**********@sparta.btinternet.com...
Hi,

Im trying to use a sesson statement within an SQL Statement:

sql = "SELECT * FROM tblNumbers WHERE AllocatedTo=" & Session("Company") & ""

And get the error:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1. /numberlist.asp, line 31

Anyone got any ideas? Surely this can only be something basic?

TIA
Oli


Jul 19 '05 #3
This SELECT * FROM tblNumbers WHERE AllocatedTo=AlternateMedia isn't correct
it should be
SELECT * FROM tblNumbers WHERE AllocatedTo='AlternateMedia'

And don't use select * in production code

Mike

"Oli" <ol*@NOSPAMoliwoods.co.uk> wrote in message
news:bq**********@sparta.btinternet.com...
SELECT * FROM tblNumbers WHERE AllocatedTo=AlternateMedia

Which is correct! Just noticed that the error is not with that line....
Line 33 is:

rs.Open sql, cn

What does "Expected 1" mean?

Thanks!
Oli

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:em**************@TK2MSFTNGP09.phx.gbl...
sql = "SELECT * FROM tblNumbers WHERE AllocatedTo=" & Session("Company")

RESPONSE.WRITE SQL
RESPONSE.END

What does that show you?

Ray at work
"Oli" <ol*@NOSPAMoliwoods.co.uk> wrote in message
news:bq**********@sparta.btinternet.com...
Hi,

Im trying to use a sesson statement within an SQL Statement:

sql = "SELECT * FROM tblNumbers WHERE AllocatedTo=" &
Session("Company")
& ""

And get the error:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1. /numberlist.asp, line 31

Anyone got any ideas? Surely this can only be something basic?

TIA
Oli



Jul 19 '05 #4
Oli wrote:
SELECT * FROM tblNumbers WHERE AllocatedTo=AlternateMedia

Which is correct!
No, it is not correct. Strings need to be delimited in queries.This is
correct:
SELECT * FROM tblNumbers WHERE AllocatedTo='AlternateMedia'
Just noticed that the error is not with that
line.... Line 33 is:

rs.Open sql, cn

What does "Expected 1" mean?


That's not the whole error message. The whole message is "Too few
parameters. Expected 1."

Because you did not delimit the word AlternateMedia, Jet looked for a field
named AlternateMedia in your table. When it did not find one, it treated
AlternateMedia as a parameter. Since you did not provide a value for the
parameter, it returned the error you reported. It's "expecting" a value for
"1" parameter.

If you had copied and pasted that query from the browser window into the SQL
View of the Access Query Builder and tried to run it, you would have been
prompted for a value for AlternateMedia. (this is how you should debug your
queries)

Your code should be changed to:

sql = "SELECT * FROM tblNumbers WHERE AllocatedTo='" & _
Session("Company") & "'"
Better yet, instead of using dynamic sql, you should use a saved parameter
query. A Google search should find plenty oif examples of this.

HTH,
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 19 '05 #5
Hi,

Change your SQL statement to this:-
sql = "SELECT * FROM tblNumbers WHERE AllocatedTo='" & Session("Company") &"'"

Because, tour AllocatedTo field must be a VarChar or Char data field. But you wnat to enter a Numeric data into it.

Hope this helps.

Bhaskardeep Khaund
Jul 19 '05 #6
Oli
Thanks Guys!
"Bob Barrows" <re******@NOyahoo.SPAMcom> wrote in message
news:OF**************@TK2MSFTNGP09.phx.gbl...
Oli wrote:
SELECT * FROM tblNumbers WHERE AllocatedTo=AlternateMedia

Which is correct!
No, it is not correct. Strings need to be delimited in queries.This is
correct:
SELECT * FROM tblNumbers WHERE AllocatedTo='AlternateMedia'
Just noticed that the error is not with that
line.... Line 33 is:

rs.Open sql, cn

What does "Expected 1" mean?


That's not the whole error message. The whole message is "Too few
parameters. Expected 1."

Because you did not delimit the word AlternateMedia, Jet looked for a

field named AlternateMedia in your table. When it did not find one, it treated
AlternateMedia as a parameter. Since you did not provide a value for the
parameter, it returned the error you reported. It's "expecting" a value for "1" parameter.

If you had copied and pasted that query from the browser window into the SQL View of the Access Query Builder and tried to run it, you would have been
prompted for a value for AlternateMedia. (this is how you should debug your queries)

Your code should be changed to:

sql = "SELECT * FROM tblNumbers WHERE AllocatedTo='" & _
Session("Company") & "'"
Better yet, instead of using dynamic sql, you should use a saved parameter
query. A Google search should find plenty oif examples of this.

HTH,
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 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jay | last post by:
G'day all This registration form checks for the submit button then displays the next form from the include statement. But before it displays the next form it will check to make sure the user...
3
by: Robert Mark Bram | last post by:
Hi All! I have the following two methods in an asp/jscript page - my problem is that without the update statement there is no error, but with the update statement I get the following error: ...
4
by: James E Koehler | last post by:
I can't get the WHILE statement to work in MySQL. The version of MySQL that I am using is: Ver 12.16 Distrib 4.0.6-gamma, for Win95/Win98 (i32) running on Windows MX. Here is the relevant...
1
by: Jack | last post by:
Hi, I got a asp page where I am getting the following error. (Line 126 is actually the RS.open statement.) ERROR MESSAGE Technical Information (for support personnel) Error Type:
15
by: Nerox | last post by:
Hi, If i write: #include <stdio.h> int foo(int); int main(void){ int a = 3; foo(a); }
7
by: kosta | last post by:
hello! one of my forms communicates with a database, and is supposed to add a row to a table using an Insert statement... however, I get a 'oledb - syntax error' exception... I have double...
1
by: amitbadgi | last post by:
HI i am getting the foll error while conv an asp application to asp.net Exception Details: System.Runtime.InteropServices.COMException: Syntax error in UPDATE statement. Source Error: Line...
13
by: eman1000 | last post by:
I was recently looking at the prototype library (http://prototype.conio.net/) and I noticed the author used the following syntax: Object.extend(MyObj.prototype, { my_meth1: function(){},...
20
by: John Salerno | last post by:
I'm starting out with this: try: if int(text) 0: return True else: self.error_message() return False except ValueError: self.error_message()
8
by: Guybrush Threepwood | last post by:
This is a simplified example of a problem I'm having: typedef struct node { int a; int b; } NODE; Somewhere in my code following lines can be found: switch(op) {
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.