Passing a parameter to Database Result Query

P

Pierre de Beer

Hi

I am creating a ASP page that displays the "Database Result" from 4 SQL
tables. This works
well if I hard code the query criteria.

The problem is to pass a parameter to the web bot to retrieve the correct
records. I define a variable MyAppId in the form and by calling the variable
I can see that the variable is visible in the form.



I use "Where (AppId = ::MyAppId::)" in the query expression. The web page
returns an error informing me that the value of the parameter can not be
blank. When I define a default value for MyAppId the form retrieves the data
perfectly for the record that is = to the default value. It seems that the
"webbot bot" is executed before the variable is known.



I attempted to define the variable in the <head> tag of the form with the
same result. If you attempt to insert the variable in the FrontPage
component FrontPage informs you that the component has changed and the
changes will be lost when saving the form.



Please help. Is there a way around this?



Kind regard



Pierre
 
T

Thomas A. Rowe

Easy to accomplish when you learn to hand code.

<%
MyAppID = Request.Form("MyAppID")

'If AppID is a text field then:
SQL = "SELECT * FROM TableName WHERE AppID = '" & MyAppID & "' "

'If AppID is a numeric field then:
SQL = "SELECT * FROM TableName WHERE AppID = " & MyAppID

%>
--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
==============================================
If you feel your current issue is a results of installing
a Service Pack or security update, please contact
Microsoft Product Support Services:
http://support.microsoft.com
If the problem can be shown to have been caused by a
security update, then there is usually no charge for the call.
==============================================
 
P

Pierre de Beer

Than You for this. This is exactly how i retrieve the parameter from the
calling form.



My Problem is to pass the parameter to the fromtpage component, my SQL
string looks something like this;



SELECT Matter.*, Matter_Elements.*
FROM Matter INNER JOIN
Matter_Elements ON Matter.AppId =
Matter_Elements.AppId
WHERE (Matter.AppId = ::MyAppID::)



How will I use your example to accomplish this?



Kind Regards



Pierre
 
T

Thomas A. Rowe

Sorry, I don't work with Joins, as I prefer to call each table separately as needed.

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
==============================================
If you feel your current issue is a results of installing
a Service Pack or security update, please contact
Microsoft Product Support Services:
http://support.microsoft.com
If the problem can be shown to have been caused by a
security update, then there is usually no charge for the call.
==============================================
 
P

Pierre de Beer

I could have used this example

SELECT * FROM Matter WHERE (AppId = ::MyAppID::)

Kind Regards

Pierre
 
T

Thomas A. Rowe

Well ?

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
==============================================
If you feel your current issue is a results of installing
a Service Pack or security update, please contact
Microsoft Product Support Services:
http://support.microsoft.com
If the problem can be shown to have been caused by a
security update, then there is usually no charge for the call.
==============================================
 
P

Pierre de Beer

Thank You
Kind Regards
Pierre


Thomas A. Rowe said:
Well ?

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
==============================================
If you feel your current issue is a results of installing
a Service Pack or security update, please contact
Microsoft Product Support Services:
http://support.microsoft.com
If the problem can be shown to have been caused by a
security update, then there is usually no charge for the call.
==============================================
 
T

Thomas A. Rowe

You are welcome!

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
==============================================
If you feel your current issue is a results of installing
a Service Pack or security update, please contact
Microsoft Product Support Services:
http://support.microsoft.com
If the problem can be shown to have been caused by a
security update, then there is usually no charge for the call.
==============================================
 
P

Pierre de Beer

It is working 100% . It was accomplished without any hand coding.

Kind Regards
Pierre
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top