Welcome to WebmasterWorld Guest from 54.167.0.111

Forum Moderators: ocean10000

Message Too Old, No Replies

sql for stored query?

sql, stored, query, queries, procedures, ms access

     

KRMwebdesign

8:10 am on Jan 21, 2011 (gmt 0)

5+ Year Member



Hi all,
I want to write a stored query for my website using an access database. What is I want is to write a statement like "SELECT * FROM MYTABLE WHERE TABLE_ID = " & (request.querystring("myID")) & "" but i don't know how to write the vbscript code in it or get the myID in the URL. Can anyone help me here?

Ocean10000

2:41 pm on Jan 24, 2011 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Normally you would create a link from another page with the myID in the url for the user to click on. Once they click on that link the url will have the querystring myID for you to use.

KRMwebdesign

3:50 pm on Jan 24, 2011 (gmt 0)

5+ Year Member



Sorry I think you miss-understand. I mean, in the MS access database I want to write a query that I can put on my page. So for instance a simple query will look like this: Select * From Mytable;

What I need to do is write an access query so it calls the id from the URL but from within the database if you understand?

topr8

6:04 pm on Jan 24, 2011 (gmt 0)

WebmasterWorld Senior Member topr8 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



access cannot (AFAIK) get variable values from your web page directly.

you need to use vbscript on your asp page in order to 'connect' to access and send the variables you need.

KRMwebdesign

6:08 pm on Jan 24, 2011 (gmt 0)

5+ Year Member



ok so it would be like sql = "myQuery" & (request.querystring("ID")) & ""?

So how would the SQL in my access query go? Would it be something like: "SELECT * FROM MYTABLE WHERE ID = ID;" ?

bmcgee

4:55 am on Jan 25, 2011 (gmt 0)

10+ Year Member



It's been ages since I used a prepared query in Access, but try putting [] around the variable:
SELECT * FROM MYTABLE WHERE ID = [ID]

Then you use a Command object, set the commandtext to be "myQuery" and use the Parameters.Add() method to define your parameter appropriately.

KRMwebdesign

4:11 pm on Jan 25, 2011 (gmt 0)

5+ Year Member



Thanks bmcgee! I will try that.

Thanks again.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month