Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 16th, 2006, 06:28 AM
Authorized User
 
Join Date: Sep 2003
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Default Just a matter of syntax

Hi, I am in trouble again !
from this

<form method="get" action= "<%= strURL %>">
  <select name="headSearch">
    <option>head1</option>
    <option>head2</option>
    <option>body1</option>
    <option>body2</option>
    </select>
<input type="submit" value="Submit Here" />
  </form>

          I am tring to use the result to do a select Distinct

objDC.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & myPath & ";"
Set objRS = Server.CreateObject("ADODB.Recordset")

strSQL = "SELECT DISTINCT "'headSearch'" FROM aefe ORDER BY "'headSearch'",
objRS.Open strSQL, objDC, 0, 1
%>
            I am having problems getting the syntax correct in
            the line above

objRS.Open strSQL, objDC, 0, 1
%>

            When I get it correct i then need

<div>
  <form method="get" action= "<%= strURL %>">
    <select name="search">
      <option>--- Select Head Type ---</option>
      <% Do While Not objRS.EOF %>
      <option value= "<%=objRS.Fields("head1")%>"><%=objRS.Fields("head 1")%></option>
      <% objRS.MoveNext
    Loop %>
    </select>

            I simply need to replace the "head1 with the Variable

<%=objRS.Fields("head1")%>">
with
<%=objRS.Fields("headSearch")%>">

           but I am ubnsure of the syntax here also

Pls Help

topshed
 
Old January 16th, 2006, 06:03 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

;;;I am tring to use the result to do a select Distinct
You wont get a result out of this select box because the option tags have no values, you need:
<option value="someValue">head1</option>

BTW: any reason you are using a get inside your form tag? I would suggest a post. If you choose to use a get then change:
trim(request.form("headSearch"))
To
trim(request.quesrystring("headSearch"))
In the sql below

When you do have values being posted to place this value inside you sql you need something like:
strSQL = "SELECT DISTINCT " & trim(request.form("headSearch")) & " FROM aefe ORDER BY " & trim(request.form("headSearch"))& "" ,objRS.Open strSQL, objDC, 0, 1



Wind is your friend
Matt
 
Old January 16th, 2006, 11:03 PM
Authorized User
 
Join Date: Sep 2003
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Mat, enlightening and very Helpfull

Topshed





Similar Threads
Thread Thread Starter Forum Replies Last Post
help syntax please khautinh SQL Server 2000 1 August 26th, 2006 02:47 AM
Syntax Error Cinderella Classic ASP Basics 4 February 1st, 2005 05:13 PM
c# syntax msrnivas .NET Web Services 2 October 15th, 2004 01:26 AM
syntax errors Adam H-W Classic ASP Databases 4 July 2nd, 2004 07:44 AM
Syntax Error snoopy92211 Access VBA 3 June 23rd, 2004 08:26 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.