?
Solved

How do I query from multiple URL parameters

Posted on 2005-02-27
6
Medium Priority
?
567 Views
Last Modified: 2010-04-25
How can I use Dreamweave MX and multiple URL parameters to query my database?

For example: .........page.asp?month=02&day=26

Here is my current code, where I am only accepting 'month' in the URL parameter:

<%
Dim rs_BlogDate__MMColParam
rs_BlogDate__MMColParam = "1"
If (Request.QueryString("Month") <> "") Then
  rs_BlogDate__MMColParam = Request.QueryString("Month")
End If
%>

<%
Dim rs_BlogDate
Dim rs_BlogDate_numRows

Set rs_BlogDate = Server.CreateObject("ADODB.Recordset")
rs_BlogDate.ActiveConnection = MM_conn_Blog_STRING
rs_BlogDate.Source = "SELECT * FROM Data WHERE Month = " + Replace(rs_BlogDate__MMColParam, "'", "''") + ""
rs_BlogDate.CursorType = 0
rs_BlogDate.CursorLocation = 2
rs_BlogDate.LockType = 1
rs_BlogDate.Open()

rs_BlogDate_numRows = 0
%>

I'd prefer to do this using Dreamweaver, but if I have to do it manually I will. A better grade will go to someone who can help me do this using Dreamweaver Server Behaviors rather than manual coding.

Thanks so much,
Matt Stanzel

0
Comment
Question by:mattboy_slim
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 8

Expert Comment

by:alexhogan
ID: 13419770
Matt,

This is actually pretty easy to do.

In DW go to the Application section.

(I'll assume that you already have a database connection)

Select the bindings tab and create a new recordset.

Select the 'Advanced' button.

I'm using the NorthWind database for this example but you'll be able to understand it clearly.

Careate a SQL statement using the tree below by selecting the table fields that you want and then the 'Select' button and then your conditional field and the 'Where' button.

After creating a SQL statement you will have something that looks like this;

SELECT ProductName, CategoryID
FROM Products
WHERE ProductID

You want to add a variable to the 'Where' clause...

SELECT ProductName, CategoryID
FROM Products
WHERE ProductID = iProdID

Now in the variables section of the Advance Query Dialog box you will enter your variable name in the name section;

Name                           Default Value                    Runtime Value
iProdID

You will also want to enter a default value..,

Name                           Default Value                    Runtime Value
iProdID                          1

And finally a runtime value..,

Name                           Default Value                    Runtime Value
iProdID                          1                                   Request.QueryString("ProductID")

The runtime value is where you get the url parameter in this argument.  In ASP 'Request.QueryString()' gets the URL parameters and 'Request.Form()' gets the values from a form that is submitted.  You put the name of the field that you are looking to return data on and the variable that will contain that value.

The above example will get '121' from the following url..,

http://www.mydomain.com/getme.asp?iProdID=121
0
 
LVL 2

Author Comment

by:mattboy_slim
ID: 13419982
Alex, sorry, I did not communicate my issue well enough.

Right now, I am querying against the URL parameter "Month", but would like to query against multiple parameters, such as "Month" and "Day". So I have the first part done (what you have explained above), but would like to query an additional URL parameter also.

Thanks again,
Matt
0
 
LVL 8

Accepted Solution

by:
alexhogan earned 1000 total points
ID: 13420029
OK..,

So you just add another variable to the variables list and another condistion to the 'Where' clause.

SELECT ProductName, CategoryID
FROM Products
WHERE ProductID = iProdID
AND CatagoryID = iCatID

Name                           Default Value                    Runtime Value
iProdID                          1                                   Request.QueryString("ProductID")
iCatID                            1                                   Request.QueryString("CategoryID")

http://www.mydomain.com/getme.asp?iProdID=121&iCatID=7
0
On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

 
LVL 2

Author Comment

by:mattboy_slim
ID: 13425365
Thanks for the help so far Alex, I'm still having trouble, though your solution did fix me up. I'll show screenshots and URLs with their results
====================================================================

Single URL Parameter, works fine:
http://www.mattstanzel.com/images/ee_rs-01.gif
URL gives me two results from the day "26", works correctly
http://www.mattstanzel.com/page.asp?day=26

=======================================

When I add the dual Request.Querystrings, Single URL parameters do not work anymore:
http://www.mattstanzel.com/images/ee_rs-02.gif
URLs give me no results:
http://www.mattstanzel.com/page.asp?day=26
http://www.mattstanzel.com/page.asp?month=02

=======================================

Is this how it is supposed to work? When I add the ability to query using multiple URL parameters, does it disable my ability to use only a single URL parameter, or do I have to use "IF" statements to determine whether there is a single or double URL parameters?

Thanks so much,
Matt

0
 
LVL 8

Expert Comment

by:alexhogan
ID: 13429155
Your URL should be;

http://www.mattstanzel.com/page.asp?month=02&day=26

That will give you the results you want.
0
 
LVL 8

Expert Comment

by:alexhogan
ID: 13429165
You will have to use some kind of branching statement to distinguish between single and multiple url params.
0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I still run into .cgi files every now and then. In some instances, I actually prefer the simplicity of a .cgi script to other options. Since I use DreamWeaver extensively, what I needed was a way to open .cgi scripts in Dreamweaver. And I wanted to …
This article is very specific and is only intended to help if you are installing Dreamweaver 8 in a Windows 7 environment with Office 2007 installed.   I'm not sure why Microsoft tends to release OS' that should not be released but they do.  Windows…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question