Forum Moderators: open

Message Too Old, No Replies

ASP problem Error

         

rigg_1

6:46 pm on Oct 20, 2002 (gmt 0)

10+ Year Member



I recieve the following error-message:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC Microsoft Access Driver] Syntax error in string in query expression 'id = ''.

/nybygge/community_1_/whois.asp, line 19
____________________________________

here is whois.asp around that lines:

Set Connect = Server.CreateObject("ADODB.Connection")
Connect.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("members.mdb")&";pwd=pwd"

Set RecSet = Server.CreateObject("ADODB.Recordset")

Addera = "SELECT * FROM members where id = '" & Request.QueryString("checkid") '<----line 19

Can someone help me out with this?!

/Rigg

Dreamquick

8:21 pm on Oct 20, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



On the surface of it it sounds a lot like you haven't given it a value but to be sure you'd need to see the actual SQL which is executing and not the SQL you *think* is executing.

- Tony

Iguana

9:20 pm on Oct 20, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Shouldn't it be

Addera = "SELECT * FROM members where id = '" & Request.QueryString("checkid") & "'"

otherwise the SQL executed is
SELECT * FROM members where id = '1234
with no trailing apostrophe and therefore fails

shady

9:24 pm on Oct 20, 2002 (gmt 0)

10+ Year Member



It certainly should! Beat me to it....

rigg_1

10:15 pm on Oct 20, 2002 (gmt 0)

10+ Year Member



Ok, thanks! i'll give it a try first time when i came home from work and then i let you know...

Woz

1:44 am on Oct 21, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld rigg_1

You do have Syntax Errors in your SQL string,

If CheckID is a number field

"SELECT * FROM members where id = " & cint(Request.QueryString("checkid")) & ";"

(do the cint just to be sure)

Or If CheckID is a Text Field

"SELECT * FROM members where id = '" & Request.QueryString("checkid") & "';"

In both cases you need the ; at the end.

I think that should fix the problem.

Onya
Woz

rigg_1

5:56 am on Oct 21, 2002 (gmt 0)

10+ Year Member



Ok, folks....thanks for your assistance. None of the suggestions abowe was working!
Got thrugh a similar file in an old backup and found this---
believe it or not, here is a working row:

Addera = "Select * From members Where id = " &Request.QueryString("checkid")

strange?!

rigg ;)

rigg_1

7:48 am on Oct 21, 2002 (gmt 0)

10+ Year Member



BUT.... it is instable! sometimes it fails. I have noticed that after logout/relogin i have to refresh the browser, otherwise the same error occurs!

Cat it some problems with the session("id")? The link leading to this is for a user to change his settings:
<a href="whois.asp?id=<%=Request.QueryString("id")%>&change=yes&checkid=<%=Session("id")%>

Another link, just to read the settings on any user is:
<a href="whois.asp?checkid=<%=RecSet("ID2")%>
and that one never fails!

Grumpus

12:31 pm on Oct 21, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I can't tell because you haven't said if the ID is a number or a string, but if it's a string, it's likely failing on ID's that have a space in them. A recordset is going to be formatted for processing, but your URL string is going to have a %20 in there. Try doing: "HTMLEncode(Request("CheckID"))". That will format the URL string so that if it's got oogly URL encoded characters in it that they are transformed to something ready for processing.

G.

rigg_1

5:24 pm on Oct 21, 2002 (gmt 0)

10+ Year Member



"id" is a primary key in the database, counter, so it's always number

tomasz

3:42 pm on Oct 22, 2002 (gmt 0)

10+ Year Member



Look in you original post, It looks like your source page is not passing right parameter from time to time. You need to make sure that it passes corect one.

dim sId

sId= val(Request.QueryString("checkid"))

if sId = 0 then
'error invalid id

end if

Addera = "Select * From members Where id = " & cstr(sId)

rigg_1

4:45 pm on Oct 23, 2002 (gmt 0)

10+ Year Member



That one gives:

Microsoft VBScript runtime error '800a000d'

Type mismatch: 'val'

/nybygge/community_1_/whois.asp, line 16

tomasz

6:43 pm on Oct 23, 2002 (gmt 0)

10+ Year Member



Try this

dim sId

sId= Request.QueryString("checkid")

if sId = "" then
'error invalid id you can put default i.e. -0
'sId = "0"
end if

Addera = "Select * From members Where id = " & sId

aspdaddy

7:50 pm on Oct 23, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>I have noticed that after logout/relogin i have >to refresh the browser...

Are you stopping the page from caching &
also checking for sessions timing out?

<a href="whois.asp?id=<%=Request.QueryString("id")%>&change=yes&checkid=<%=Session("id")%>

This is missing a final "

Iguana

8:34 pm on Oct 23, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have an ASP site on a free provider and the thing I have noticed is that POST parameters are, for some reason, not always picked up even I know they are always passed.

This is my third free host and this happened a lot more on the prvious two. I've never had the error on my own IIS or in 3 years at work