Wrox Programmer Forums
|
ASP Pro Code Clinic As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Pro Code Clinic 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 July 22nd, 2003, 01:27 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default asp query problem

Hi,

How I can select four value from the asp page and retrieve records from sql server. What asp query will use.
There is problem in following form. Please help.


<form method=post action=plots\dwg_list3.asp id=sect_area name=sect_area>
<TABLE cellSpacing=1 cellPadding=1 width="75%" border=1>

  <TR>
    <TD>Enter Sector Number :</TD>
    <TD><INPUT id=sect_count style="WIDTH: 182px; HEIGHT: 22px" size=23
    name=sect_count></TD>
    <TD><INPUT id=dtype type=checkbox name=dtype>&nbsp;Plots</TD></TR>
  <TR>
    <TD>Select Area :</TD>
    <TD>

    <SELECT id=sect_area name=sect_area> <OPTION selected>
<%
dim ssql
set cn=server.CreateObject("adodb.connection")
cn.ConnectionString="Provider=SQLOLEDB.1;Integrate d Security=SSPI;Persist Security Info=False;Initial Catalog=dcil;Data Source=AUHTRIPSVR2"
cn.Open

ssql="select distinct sect_area from sectors order by sect_area"

set rs=cn.Execute(ssql)
do while rs.eof=false
Response.Write("<option value='" & rs("sect_area") & "'>")
Response.Write(rs("sect_area") )
rs.movenext
loop
%>

  </OPTION></SELECT>
        </TD>
    <TD><INPUT id=dtype2 type=checkbox
  name=dtype2>&nbsp;Utilities</TD></TR></TABLE>

</center></div>

<p align="center"><input id=sect_area name=sect_area title="Show Drawings" type="submit" value="Show Drawings"></p>

</form>


what query will use if four value select in asp page, there is problem in this query. It retrieve all records I want to retrieve only select records.

ssql="SELECT drawings.name,drawings.dtype,sectors.sect_count,dr awings.location,sectors.sect_area from drawings, sectors where drawings.name = sectors.name "

regards.

Mateen
 
Old July 22nd, 2003, 04:23 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 231
Thanks: 0
Thanked 0 Times in 0 Posts
Default

How can you tell if the record is a select record? If the database table has a field 'Type' which can contain the value 'select' to identify that it is a select record then your SQL statement would look like this:

Code:
SELECT DISTINCT sect_area FROM sectors WHERE Type = 'select' ORDER BY sect_area
Also there is a problem with the HTML source generated using your ASP page, you are not closing each option tag created in the loop.

Code:
Response.Write("<option value='" & rs("sect_area") & "'>")
Response.Write(rs("sect_area") )
Response.Write "</option>" 'This is the line you need to add
And finally, what is the relevance of the SQL statement you included at the end of your post?
Quote:
quote:ssql="SELECT drawings.name,drawings.dtype,sectors.sect_count,dr awings.location,sectors.sect_area from drawings, sectors where drawings.name = sectors.name "
It does not seem to help describe your problem at all.

Regards
Owain Williams





Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP Paging Query Bozmeister ASP.NET 3.5 Basics 3 November 8th, 2008 02:20 PM
crosstab query and asp tulincim Classic ASP Databases 0 September 13th, 2005 03:00 PM
how query 2 tables in asp method Classic ASP Databases 5 March 19th, 2005 12:24 PM
Sql Query in ASP mateenmohd SQL Server 2000 3 October 29th, 2003 12:16 AM





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