Welcome to WebmasterWorld Guest from 54.196.244.186

Forum Moderators: ocean10000

Message Too Old, No Replies

sql for stored query?

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

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

Junior Member

5+ Year Member

joined:Sept 11, 2009
posts: 108
votes: 0


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?
2:41 pm on Jan 24, 2011 (gmt 0)

Administrator

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month

joined:Jan 14, 2004
posts:852
votes: 0


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.
3:50 pm on Jan 24, 2011 (gmt 0)

Junior Member

5+ Year Member

joined:Sept 11, 2009
posts: 108
votes: 0


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?
6:04 pm on Jan 24, 2011 (gmt 0)

Senior Member

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

joined:Apr 19, 2002
posts:3171
votes: 8


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.
6:08 pm on Jan 24, 2011 (gmt 0)

Junior Member

5+ Year Member

joined:Sept 11, 2009
posts: 108
votes: 0


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;" ?
4:55 am on Jan 25, 2011 (gmt 0)

Full Member

10+ Year Member

joined:May 14, 2001
posts:262
votes: 0


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.
4:11 pm on Jan 25, 2011 (gmt 0)

Junior Member

5+ Year Member

joined:Sept 11, 2009
posts: 108
votes: 0


Thanks bmcgee! I will try that.

Thanks again.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members