Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 14th, 2005, 04:02 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
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.

    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 &"%'")
Ayrshire Minis - a Mini E-Community
Reply With Quote
  #2 (permalink)  
Old June 17th, 2005, 07:39 AM
Friend of Wrox
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post

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.:

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!



Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 05:03 AM.

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