Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. 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 Databases 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 June 14th, 2005, 04:02 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default dynamic MySQL hit

How can i make this dynamic as not all fields will be available everytime as the variable values are coming from a form field.

Code:
    set rs1=con.execute("select * from net_fares where company_id = '"& company_id &"' and contract_id = '"& contract_id &"' and dep like '%"& dep &"%' and arr like '%"& arr &"%' and via like '%"& via &"%' and season = '%"& season &"%' and cabin = '%"& cabin &"%' and zone = '%"& zone &"%' and region = '%"& region &"%'")
www.crmpicco.co.uk
www.crmpicco.co.uk.tt
www.milklemonadechocolate.uk.tt
www.griswolds.uk.tt
www.piccosmini.co.uk.tt
www.morton.uk.tt
__________________
_______________________
Ayrshire Minis - a Mini E-Community
http://www.ayrshireminis.com
http://www.crmpicco.co.uk
 
Old June 17th, 2005, 07:39 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Not exactly sure what you mean, but if the variables company_id etc are coming from a form field, you could build the query up before executing, e.g.:

Code:
Dim query: query = "SELECT * FROM net_fares "
Dim where: where = ""
If company_id <> "" Then
    where = where & "AND companyid = '" & company_id & "' "
End If
... process other fields ...
If where <> "" Then
    ' add the where clause without the initial "AND"
    query = query & Mid(where, 5)
End If
Set rs1 = con.Execute(query, , adCmdText)
BTW, why not split your code onto separate lines using "_" if lines are very long, makes it easier to read and not so hard to reply to on the forums as well!

HTH,

Chris






Similar Threads
Thread Thread Starter Forum Replies Last Post
Hit-count for dynamic page Steve777 ASP.NET 2.0 Basics 2 June 24th, 2008 11:09 AM
javascript remove bad characters for MySQL db hit crmpicco Javascript How-To 25 March 29th, 2006 06:34 AM
MySQL hit to batabase with ASP crmpicco Classic ASP Databases 19 November 24th, 2005 10:09 AM
dynamic inserting into mysql using C code qassem MySQL 0 March 28th, 2005 08:34 AM





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