Welcome to WebmasterWorld Guest from 18.104.22.168 , register , free tools , login , search , subscribe , help , library , announcements , recent posts , open posts Pubcon Platinum Sponsor
sql for stored query? sql, stored, query, queries, procedures, ms access KRMwebdesign msg:4256055 8:10 am on Jan 21, 2011 (gmt 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?
Ocean10000 msg:4257338 2:41 pm on Jan 24, 2011 (gmt 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. KRMwebdesign msg:4257370 3:50 pm on Jan 24, 2011 (gmt 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? topr8 msg:4257449 6:04 pm on Jan 24, 2011 (gmt 0)
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 msg:4257450 6:08 pm on Jan 24, 2011 (gmt 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;" ? bmcgee msg:4257712 4:55 am on Jan 25, 2011 (gmt 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. KRMwebdesign msg:4257881 4:11 pm on Jan 25, 2011 (gmt 0)
Thanks bmcgee! I will try that. Thanks again.