Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Asp Query String Help 1

Status
Not open for further replies.

Manic

Programmer
Feb 28, 2001
343
GB
This has been bugging me all day

I have kept coming back to it and trying to sort it but to no avail

Any help woould be appriciated

I Have the following code
Code:
<%
Dim adoCon, rsDetails, strSQL, RecordNo
RecordNo = String(Request.QueryString("Problem_Level"))
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("work.mdb")
Set rsDetails = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM Details WHERE Problem_Level=" & RecordNo
rsDetails.Open strSQL, adoCon 
%>

I am feeding it with this link

Code:
[URL unfurl="true"]http://............show_level.asp?Level=High[/URL]

I get the following error

Code:
Error Type:
Microsoft VBScript runtime (0x800A01C2)
Wrong number of arguments or invalid property assignment: 'String'
/work/show_level.asp, line 10

Manic
-----------------------------
I've broken it again !!
-----------------------------
 
You are trying to convert from a url parameter that doesn't exist:


RecordNo = String(Request.QueryString("Level"))

and if you are looking for a string in the sql statement you will need to use

strSQL = "SELECT * FROM Details WHERE Problem_Level='" & RecordNo &"'"

hth

simon
 
I have tried using Level and Problem_Level but I still get the same error
Code:
Error Type:
Microsoft VBScript runtime (0x800A01C2)
Wrong number of arguments or invalid property assignment: 'String'
/work/show_level.asp, line 10

This is why I am confused

Manic
-----------------------------
I've broken it again !!
-----------------------------
 
have you changed the sql as well, which one is line 10?

why can't you simply use:

If Len(Request.QueryString("Level"))>0 Then

strSQL = "SELECT * FROM Details WHERE Problem_Level='" & Request.QueryString("Level") &"'"

End If


?

 
not sure what you are trying to do

the string function builds a string of chars x no in length
Code:
mystring = string(10,"z")
' mystring now is "zzzzzzzzzz"

maybe what you need is

Code:
RecordNo = CStr(Request.QueryString("Level"))


Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
Chris,

Would you need to implicitly convert into string? I wouldn't think this was necessary from a querystring?

The sql statement also seems to suggest that manic is looking for the querystring to be an int (no quotes) not a string

Simon
 
What I am trying to do is pass a string from a link into the next page for the query

I use this a lot with CLng but this is the first time with a String.

I have tried
Code:
<%
Dim adoCon, rsDetails, strSQL, RecordNo
RecordNo = CStr(Request.QueryString("Level"))
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("work.mdb")
Set rsDetails = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM Details WHERE Problem_Level=" & RecordNo
rsDetails.Open strSQL, adoCon 
%>

But I still get an error
Code:
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
/work/show_level.asp, line 15

line 15 is
Code:
rsDetails.Open strSQL, adoCon

Thanks for all the help so far, and I hope I am making sense.

Manic
-----------------------------
I've broken it again !!
-----------------------------
 
try this:

<%
Dim adoCon, rsDetails, strSQL, RecordNo
RecordNo = "1"
RecordNo = CStr(Request.QueryString("Level"))
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("work.mdb")
Set rsDetails = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM Details WHERE Problem_Level=" & RecordNo
rsDetails.Open strSQL, adoCon
%>

If this doesn't solve it - then use

response.write strSQL
response.end

before

rsDetails.Open strSQL, adoCon


and post what is displayed
 
The error I get is

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

Line 19 is rsDetails.Open strSQL, adoCon

This is what is stored in strSQL

SELECT * FROM Details WHERE Problem_Level=High

and it works for all levels (low and medium)



Manic
-----------------------------
I've broken it again !!
-----------------------------
 
as far as i remember "_" is an escape character in SQL / Access you will need to enclose field/table names with this character in them inside []'s
i.e. :
SELECT * FROM Details WHERE [Problem_Level]=High

also note: your "HIGH" value is not encased in single quotes either.

[thumbsup2]DreX
aKa - Robert
 
Go back to my earlier post, you are using a string to search with:

SELECT * FROM Details WHERE Problem_Level=High


should be

SELECT * FROM Details WHERE Problem_Level='High'


so you will need:


<%
Dim adoCon, rsDetails, strSQL, RecordNo
RecordNo = "1"
RecordNo = CStr(Request.QueryString("Level"))
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("work.mdb")
Set rsDetails = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM Details WHERE Problem_Level='" & RecordNo &"'"
rsDetails.Open strSQL, adoCon
%>

good luck

simon

 
Thanks to you all for your help.

It is now working.

Task 1/1000 done for today :)

Manic
-----------------------------
I've broken it again !!
-----------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top