
July 19th, 2005, 09:55 AM
| | | SQL Statement Error?!
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 | 
July 19th, 2005, 09:55 AM
| | | Re: SQL Statement Error?!
sql = "SELECT * FROM tblNumbers WHERE AllocatedTo=" & Session("Company")
RESPONSE.WRITE SQL
RESPONSE.END
What does that show you?
Ray at work
"Oli" <oli@NOSPAMoliwoods.co.uk> wrote in message
news:bqks2u$e7k$1@sparta.btinternet.com...[color=blue]
> 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
>
>[/color] | 
July 19th, 2005, 09:55 AM
| | | Re: SQL Statement Error?!
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:emui3pauDHA.1224@TK2MSFTNGP09.phx.gbl...[color=blue]
> sql = "SELECT * FROM tblNumbers WHERE AllocatedTo=" & Session("Company")
>
> RESPONSE.WRITE SQL
> RESPONSE.END
>
> What does that show you?
>
> Ray at work
>
>
> "Oli" <oli@NOSPAMoliwoods.co.uk> wrote in message
> news:bqks2u$e7k$1@sparta.btinternet.com...[color=green]
> > Hi,
> >
> > Im trying to use a sesson statement within an SQL Statement:
> >
> > sql = "SELECT * FROM tblNumbers WHERE AllocatedTo=" & Session("Company")[/color][/color]
&[color=blue][color=green]
> > ""
> >
> > And get the error:
> >
> > Error Type:
> > Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
> > [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected[/color][/color]
1.[color=blue][color=green]
> > /numberlist.asp, line 31
> >
> > Anyone got any ideas? Surely this can only be something basic?
> >
> > TIA
> > Oli
> >
> >[/color]
>
>[/color] | 
July 19th, 2005, 09:55 AM
| | | Re: SQL Statement Error?!
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" <oli@NOSPAMoliwoods.co.uk> wrote in message
news:bqksvp$hss$1@sparta.btinternet.com...[color=blue]
> 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:emui3pauDHA.1224@TK2MSFTNGP09.phx.gbl...[color=green]
> > sql = "SELECT * FROM tblNumbers WHERE AllocatedTo=" & Session("Company")
> >
> > RESPONSE.WRITE SQL
> > RESPONSE.END
> >
> > What does that show you?
> >
> > Ray at work
> >
> >
> > "Oli" <oli@NOSPAMoliwoods.co.uk> wrote in message
> > news:bqks2u$e7k$1@sparta.btinternet.com...[color=darkred]
> > > Hi,
> > >
> > > Im trying to use a sesson statement within an SQL Statement:
> > >
> > > sql = "SELECT * FROM tblNumbers WHERE AllocatedTo=" &[/color][/color][/color]
Session("Company")[color=blue]
> &[color=green][color=darkred]
> > > ""
> > >
> > > And get the error:
> > >
> > > Error Type:
> > > Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
> > > [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected[/color][/color]
> 1.[color=green][color=darkred]
> > > /numberlist.asp, line 31
> > >
> > > Anyone got any ideas? Surely this can only be something basic?
> > >
> > > TIA
> > > Oli
> > >
> > >[/color]
> >
> >[/color]
>
>[/color] | 
July 19th, 2005, 09:55 AM
| | | Re: SQL Statement Error?!
Oli wrote:[color=blue]
> SELECT * FROM tblNumbers WHERE AllocatedTo=AlternateMedia
>
> Which is correct![/color]
No, it is not correct. Strings need to be delimited in queries.This is
correct:
SELECT * FROM tblNumbers WHERE AllocatedTo='AlternateMedia'
[color=blue]
> Just noticed that the error is not with that
> line.... Line 33 is:
>
> rs.Open sql, cn
>
> What does "Expected 1" mean?[/color]
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. | 
July 19th, 2005, 09:55 AM
| | | Re: SQL Statement Error?!
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 | 
July 19th, 2005, 09:55 AM
| | | Re: SQL Statement Error?!
Thanks Guys!
"Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
news:OFsXk6auDHA.2544@TK2MSFTNGP09.phx.gbl...[color=blue]
> Oli wrote:[color=green]
> > SELECT * FROM tblNumbers WHERE AllocatedTo=AlternateMedia
> >
> > Which is correct![/color]
>
> No, it is not correct. Strings need to be delimited in queries.This is
> correct:
> SELECT * FROM tblNumbers WHERE AllocatedTo='AlternateMedia'
>[color=green]
> > Just noticed that the error is not with that
> > line.... Line 33 is:
> >
> > rs.Open sql, cn
> >
> > What does "Expected 1" mean?[/color]
>
> 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[/color]
field[color=blue]
> 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[/color]
for[color=blue]
> "1" parameter.
>
> If you had copied and pasted that query from the browser window into the[/color]
SQL[color=blue]
> 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[/color]
your[color=blue]
> 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.
>
>[/color] |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | | | What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over network members.
|