Re: SQLs

From: lc (lc_at_hotmail.com)
Date: 07/30/04


Date: Fri, 30 Jul 2004 07:12:42 -0700

Hi,

It doesnt create an error but the drop down is blank and
there is no value printed after the division =

Here is my new code:

<%@ Language=VBScript %>
<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsGuestbook 'Holds the recordset for the records in
the database
Dim strSQL 'Holds the SQL query to query the
database
Dim strSQL4

'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using
a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)};
DBQ=" & Server.MapPath("alpha.mdb")

'Create an ADO recordset object
Set rsGuestbook = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to
query the database
strSQL = "SELECT DISTINCT tblEV3Location.Division FROM
tblEV3Location ORDER BY tblEV3Location.Division;"

'Open the recordset with the SQL query
rsGuestbook.Open strSQL, adoCon
 

set cars=adoCon.execute(strSQL)
%>
<select name="Division">
        <% 'Loop through the recordset to make each entry
in the list. %>
        <% do while not cars.eof %>
                <Option value = "<%= cars(0) %>"><%= cars
(0) %></Option>
        <%cars.movenext
        loop%>
</select>

<%

strSQL4 = "SELECT DISTINCT tblEV3Location.Code,
tblEV3Location.Division FROM tblEV3Location WHERE
tblEV3Location.Division='" & Request("Division") &"';"
%>
<%set cars4=adoCon.execute(strSQL4)
%>

<select name="Code">
        <% 'Loop through the recordset to make each entry
in the list. %>
        <% do while not cars4.eof %>
                <Option value = "<%= cars4(0) %>"><%=
cars4(0) %></Option>
        <%cars4.movenext
        loop%>
</select>
<html>

<head>
<title> select </title>
</head>
<body><%="Division=" & request("Division")%>

</body>

</html>

Thank you.

>-----Original Message-----
>Howdy.
>
>Please define "doesn't work". How does it fail?
>
>Also, does putting <%="code=" & request("code")%>
immediately
>after the <body> tag display the code value you expect?
>
>Jim Buyens
>Microsoft FrontPage MVP
>http://www.interlacken.com
>Author of:
>*----------------------------------------------------
>|\---------------------------------------------------
>|| Microsoft Office FrontPage 2003 Inside Out
>||---------------------------------------------------
>|| Web Database Development Step by Step .NET Edition
>|| Microsoft FrontPage Version 2002 Inside Out
>|| Faster Smarter Beginning Programming
>|| (All from Microsoft Press)
>|/---------------------------------------------------
>*----------------------------------------------------
>
>
>"LC" <lc@hotmail.com> wrote in message
news:<6c8001c4759b$c97698f0$a501280a@phx.gbl>...
>> Hi,
>>
>> For some odd reason that code doesnt work.
>> Is there something missing at the WHERE
>> tblEV3Location.Division= ?
>>
>> Thanks.
>> >-----Original Message-----
>> >Howdy.
>> >
>> >strSQL4 = "SELECT DISTINCT tblEV3Location.Division "
& _
>> > "FROM tblEV3Location " & _
>> > "WHERE tblEV3Location.Division='" & _
>> > request("code") & "';"
>> >
>> >Jim Buyens
>> >Microsoft FrontPage MVP
>> >http://www.interlacken.com
>> >Author of:
>> >*----------------------------------------------------
>> >|\---------------------------------------------------
>> >|| Microsoft Office FrontPage 2003 Inside Out
>> >||---------------------------------------------------
>> >|| Web Database Development Step by Step .NET Edition
>> >|| Microsoft FrontPage Version 2002 Inside Out
>> >|| Faster Smarter Beginning Programming
>> >|| (All from Microsoft Press)
>> >|/---------------------------------------------------
>> >*----------------------------------------------------
>> >
>> >
>> >>-----Original Message-----
>> >>Hi,
>> >>
>> >>I have two or more sql statements that depends on
the
>> >>other on the same page. For example I have strSQL3
and
>> >>then strSQL4 will need the result from the dropdown
of
>> >>strSQL3 to start its sql.
>> >>
>> >>strSQL3 = "SELECT DISTINCT tblEV3Location.Code FROM
>> >>tblEV3Location ORDER BY tblEV3Location.Code;"
>> >>
>> >><% set cars3=adoCon.execute(strSQL3) %>
>> >><select name="Code">
>> >> <% 'Loop through the recordset to make each entry
>> >>in the list. %>
>> >> <% do while not cars3.eof %>
>> >> <Option value = "<%= cars3(0) %>"> <%=
>> >>cars3(0) %></Option>
>> >> <%cars3.movenext
>> >> loop%>
>> >></select>
>> >>
>> >>How would I do something like this where the Code is
>> the
>> >>name of the drop-down?:
>> >>strSQL4 = "SELECT DISTINCT tblEV3Location.Division
FROM
>> >>tblEV3Location WHERE
tblEV3Location.Division='Code';"
>> >>
>> >>Thanks.
>> >>
>> >>.
>> >>
>> >.
>> >
>.
>



Relevant Pages

  • Re: SQLs
    ... Microsoft FrontPage MVP ... || Web Database Development Step by Step .NET Edition ... > 'Set an active connection to the Connection object using ... > 'Create an ADO recordset object ...
    (microsoft.public.frontpage.programming)
  • Microsoft OLE DB Provider for ODBC Drivers (0x80040E10) [Microsoft][ODBC Microsoft Access Driver] To
    ... information through the page and then its going to write to database. ... 'Set an active connection to the Connection object using a DSN-less ... 'Create an ADO recordset object ... 'Initialise the strSQL variable with an SQL statement to query the ...
    (microsoft.public.inetserver.asp.db)
  • Re: ASP question global.asa
    ... The reason I assumed this is that I have a file named guestbook.asp and an attempt to open a recordset declared in global.asa failed. ... Sub Application_OnEnd ... Dim adoCon 'Holds the Database connection Object ... 'Initialise the strSQL variable with an SQL statement to query the database ...
    (microsoft.public.scripting.jscript)
  • Re: Setting subform recoursource with connection string (SQL server)
    ... I am trying to avoid having to create a odbc dns connection on every ... computer that the database will run. ... How can I set the form's recordset to a string that uses ... rst.Open strSQL, oConn ...
    (microsoft.public.access.forms)
  • Re: asp and access db - edit textarea
    ... > Dim adoCon 'Holds the Database Connection Object ... > Dim rsHome 'Holds the recordset for the record to be updated ... > 'Set an active connection to the Connection object using a DSN-less ...
    (microsoft.public.inetserver.asp.general)