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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select statement error... 4

Status
Not open for further replies.

rjn2001

Programmer
Dec 29, 2004
172
GB
Got a little something wrong with my SQL statement:
Code:
Microsoft VBScript compilation error '800a03fd' 

Expected 'Case' 

/viewjob.asp, line 10 

SELECT * FROM tblJob Where UserID = "' &UserID& '"
-------^
Code:
SELECT * FROM tblJob Where UserID = "' &UserID& '"



Richard Noon
 
change
Code:
SELECT * FROM tblJob Where UserID = "' &UserID& '"

to

[coce]
SELECT * FROM tblJob Where UserID = '" & UserID & "'"
[/code]
 
have you put your SQL string in quotes when you run it?

Show us the code where it is executed.


Tony
_______________________________________________________________
 
ack, hate when I mispell

your query should be....

Code:
SELECT * FROM tblJob Where UserID = '" & UserID & "'"
 
Try this id UserId is a numeric:

SELECT * FROM tblJob Where UserID = "&UserID

If UserId is a string then use the one suggested by pkailas

SELECT * FROM tblJob Where UserID = '" & UserID & "'"

Also i wouls suggest to wrap UserID in square braces...may be its a key word...something like this

SELECT * FROM tblJob Where [UserID] = '" & UserID & "'"

Hope this helps

-SecondToNone

 
Fester: That is my entire sql statement. I take it is wrong!

Code:
<!--#include file="security.asp" -->
<%

Dim SQL
Dim UserID


UserID = Request.QueryString ("UserID")

"SELECT * FROM tblJob Where UserID = '" & UserID & "'"

set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "D:/Websites/richard/admin/db/users.mdb"
Set objRs = conn.Execute(strSQL, , 1) 



'File: viewJob.asp
'Description: Authorised Page
%>

Richard Noon
 
strSQL= "SELECT * FROM tblJob Where UserID = '" & UserID & "'"

-SecondToNone
 
hmm.

please do this.

Code:
UserID = Request.QueryString ("UserID")

strSql = "SELECT * FROM tblJob Where UserID = '" & UserID & "'"
 
you may also want to try this...

Code:
UserID = Request.QueryString ("UserID")

strSQL = "SELECT * FROM tblJob Where UserID = '" & UserID & "'"

response.write strsql
response.end
 
I must apologise for my stupidity.

this is the output from pkailas post:
Code:
SELECT * FROM tblJob Where UserID = ''

No user ID in there, user ID is a text field, the user can type in any userid they want


Richard Noon
 
was there something in the UserID text box?

is the problem the fact you aren't returning a value?

if the answer is yes then try replacing

Code:
UserID = Request.QueryString ("UserID")

with

Code:
UserID = Request("UserID")
 
where is the code for the link with the querystring value UserID? Maybe the querystring is spelled wrong?


Tony
_______________________________________________________________
 
Hi, I cant get UserID to be returned.

This is the full code of the page, I dont know what is happening!

Code:
<!--#include file="security.asp" -->
<%

UserID =  Request.Form("UserID")


Dim SQL
Dim UserID


UserID = Request("UserID")
strSQL = "SELECT * FROM tblJob Where UserID = '" & UserID & "'"

response.write UserID
response.end

set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "D:/Websites/richard/admin/db/users.mdb"
Set objRs = conn.Execute(strSQL, , 1) 



'File: viewJob.asp
'Description: Authorised Page
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML dir=ltr xmlns-asp="null" xmlns-shell="null"><HEAD>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="copyright" content="Copyright (C) 2005 Blue Alumni Resourcing">
<META content=en-us name=MS.LOCALE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<META content="Blue Alumni Resourcing" name=keywords>
<link rel="stylesheet" type="text/css" href="css.css">
<META content="<%= Date() %>" name=last-updated>
<title><%= strUsername %>, User Panel</title>
<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" link="#3366CC" vlink="#008000" alink="#FF0000">
<%= strUsername %>
		<H1><img border="0" src="images/BARLogo.gif" width="125" height="110"> Private Page 2</H1></p>
<p align="center" style="margin-top: -1px; margin-bottom: -1px">
		&nbsp;</p>
		<table border="0" width="100%" id="table1">
			<tr>
				<td>
		<h3>Today:&nbsp;<b><%= Date() %></b> ,Welcome&nbsp;<b><%= rsCheckUser("First_Name") %>&nbsp;<%= rsCheckUser("Last_Name") %>&nbsp;(Login as: <%= strUserName %>)</b>, to 
		<%= strWebsiteName %></h3></td>
			</tr>
			<tr>
			<td>
			<BODY>
<%
If (objRs.EOF) then
%>
<P>Sorry, we do not hold any information about your previous Job history.
Else
<CENTER>
<FONT SIZE="5"><B>
Previous Job History

</B>
</FONT>
</CENTER>

<BODY>

<BR><BR>
<TABLE border=1>
<TR>
<TD>Job Start Date</TD>
<TD>Job End Date</TD>
<TD>Organisation Name</TD>
<TD>Job Title</TD>
<TD>Job Description</TD>
</TR>
<%
Do While Not (objRs.EOF)
%>
<TR>
<TD><%=objRs("JobStart")%></TD>
<TD><%=objRs("JobFinish")%></TD>
<TD><%=objRs("EmployerName")%></TD>
<TD><%=objRs("JobRole")%></TD>
<TD><%=objRs("JobDetail")%></TD>
</TR>
<%
objRs.MoveNext
Loop
%>
</TABLE>
</TABLE>
<BR>
<BR>
<A HREF="menu.asp">Return to the Main Menu</A>

			
			
			
			<tr>
				<td>
		<font face="Arial" size="2">
		<p align="center" style="margin-top: -1px; margin-bottom: -1px"><b>&nbsp;<a href="profile.asp?userid=<%=strUsername %>">View Profile</a> ||
				<a href="edit.asp?.rand=<%= Md5Hash %>">Edit Account</a> ||
				<a href="register.asp">New Sign Up</a> ||
				<a href="forgot.asp?.rand=<%= md5Hash %>">Recover Password</a> 
				|| 
		<a href="logout.asp?<%= Request.ServerVariables("QUERY_STRING")%>">Logout
		</a> </b></p>
		<p align="center" style="margin-top: -1px; margin-bottom: -1px">&nbsp;</p>
		<p>&nbsp;</p>
		<p>&nbsp;</font></td>
			</tr>
		</table>
		<!-- #include file="footer.asp" -->		
<%
End If     
objRs.Close
Set objRs=Nothing
objConn.Close
Set objConn=Nothing
%>
</body>
</html>

Richard Noon
 
if i am not wrong..you are doing this

href="profile.asp?userid=<%=strUsername %> to get the userid

use

UserID = Request.QueryString("userid")

-SecondToNone
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top