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 * FROM x WHERE y =" & Request.Form("z")?? 1

Status
Not open for further replies.

Lupo

Programmer
Oct 29, 2001
31
CH
Hi there,

I have a prob within my ASP-Pages. "page1.asp" (see code below) contains a form with dropdowns sourced from a access database table (tbl_country). I post the selected country (that's the content of the dropdown) to "page2.asp" (see code below). Within "page2.asp" serveral information about the country will (at the moment should) be displayed. The content of "page2.asp" is sourced out of a query stored in the same access database. The following error message appears. What did I wrong or what do I have to do?

The error message

Kompilierungsfehler in Microsoft VBScript- Fehler '800a03ea'

Syntax Error

/iisHelp/common/500-100.asp, line 129

elseIf (objASPError.Description > "") Then
^
Microsoft OLE DB Provider for ODBC Drivers- Fehler '80040e10'

[Microsoft][ODBC Microsoft Access Driver] 1 Parameter wurden erwartet, aber es wurden zu wenig Parameter übergeben.

/gxinternet/cont_topic/31contr.asp, line 26 <-- that's the &quot;set rstEntry = objConn.execute(strSQL)&quot; line.

The code &quot;page1.asp&quot;

Code:
<html>
<head>
</head>
</body>


<form BOTID=&quot;0&quot; METHOD=&quot;POST&quot; ACTION=&quot;page2.asp&quot;>
<select name=&quot;ctrysel&quot; size=&quot;1&quot;>
<% @language=javascript %>
<%
var conn=Server.CreateObject(&quot;ADODB.Connection&quot;);
var rs=Server.CreateObject(&quot;ADODB.Recordset&quot;);
conn.open(&quot;WP011C0203&quot;);
rs=conn.execute(&quot;SELECT * FROM tbl_country ORDER BY CountryName ASC&quot;);
while (!rs.EOF)
{
Response.write(&quot;<option>&quot;+rs(&quot;CountryName&quot;)+&quot;</option>&quot;);
rs.MoveNext();		
}
rs.close();
conn.close();
%>
</select>
<input TYPE=&quot;image&quot; src=&quot;../images/button/submit.gif&quot; value=&quot;Submit&quot; name=&quot;submit&quot;>
<!--webbot bot=&quot;SaveAsASP&quot; clientside suggestedext=&quot;asp&quot; preview=&quot; &quot; -->
</form>

</body>
</html>


The code &quot;page2.asp&quot;

Code:
<%
'Variables dimensioning
Dim objConn
Dim strSQL
Dim rstEntry
Dim strOfficeType
Dim strCity
Dim strCountryISO
Dim strCompany
Dim strAddress1
Dim strAddress2
Dim strZIP
Dim strPhone
Dim strFax
Dim strEmail
Dim strMMG

'DB connect
Set objConn=Server.CreateObject(&quot;ADODB.Connection&quot;)
objConn.ConnectionString=&quot;DSN=WP011C0203&quot;
objConn.open

'Create Recordset
strSQL =&quot;SELECT * FROM qyr_mmg WHERE CountryName =&quot; & Request.Form(&quot;ctrysel&quot;)
set rstEntry = objConn.execute(strSQL)

'Fill in variables
strOfficeType = rstEntry(&quot;OfficeType&quot;).value
strCountryISO = rstEntry(&quot;CountryISO&quot;).value
strCompany = rstEntry(&quot;Company&quot;).value
strAddress1 = rstEntry(&quot;Address1&quot;).value
strAddress2 = rstEntry(&quot;Address2&quot;).value
strZIP =rstEntry(&quot;ZIP&quot;).value
strCity = rstEntry(&quot;City&quot;).value
strPhone = rstEntry(&quot;Phone&quot;).value
strFax = rstEntry(&quot;Fax&quot;).value
strEmail = rstEntry(&quot;Email&quot;).value
strMMG = rstEntry(&quot;MMG&quot;).value

%>

<html>
<head>
</head>
<body>

The following goods are sourced from <% Response.Write Request.Form(&quot;ctrysel&quot;)%>

<ul><li> <%=strMMG%> </li></ul>

For further details to become a supplier please contact our 
<%=strOfficeType%> in <%=strCity%> who is responisble for the
selected Country of Origin <% Response.Write Request.Form(&quot;ctrysel&quot;)%>.

	<%=strCompany%>
	<%=strAddress1%>
	<%=strAddress2%>
	<%=strZIP%> <%=strCity%>
	<%=strPhone%>
	<%=strFax%>
	<%=strEmail%>

</body>
</html>

- - - - - - - - - - - - - - - - - - - - - - - - -

Can't find the bug. Thanks in advance for you help.

Dani
(BTW, i'am nearly an ASP Beginner. Sorry,...)
 
Is CountryName a text field? If so, you need to surround the value you're comparing against with single quotes like this:

strSQL =&quot;SELECT * FROM qyr_mmg WHERE CountryName ='&quot; & Request.Form(&quot;ctrysel&quot;) & &quot;'&quot;
 
Hi lobstah,

the &quot;single quotes&quot; and the &quot;&&quot;was the problem. SQL and Access is a little bit X-) but not bad..

It runs fine now!
thanks for your help

rgds Dani WEB Designer & WEB Developer (as per my working contract) and especially ASP Newbie :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top