homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

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

 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?



 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.


 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?


 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.


 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;" ?


 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:

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)

Thanks bmcgee! I will try that.

Thanks again.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved