Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Query Access Database with VBScript

 
Logged in as: Guest
arrSession:exec spGetSession 2,18,59038
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript Tutorial >> Query Access Database with VBScript
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Query Access Database with VBScript - 4/11/2008 1:35:52 PM   
  TomRiddle


Posts: 165
Score: 4
Joined: 2/7/2008
Status: offline
This is my tutorial on how to build a query that you can use in VBScript to extract information from a database.

The level of difficulty for this tutorial is beginner to intermediate.
You need to know basic VBScript syntax and need to have a copy of MS Access.

Pay attention to the SQL_query parts in the following blocks of code.


This is the code syntax for ASP

Note this code is striped down to the most basic HTML for demonstration purposes.

      

This is the Code Syntax for WSH.

Notice I have removed instances of "Server." and "MapPath" from the script.
I have also removed the HTML stuff.

      

Did you understand all that?? Don't worry if you didn't, because you don't need to understand it.
These blocks of code seem complex but all you have to understand is that they are templates with an SQL query.

There are many different examples of creating databases and tables, and reading, writing and deleting records on the Internet.
The only hard thing is the SQL query itself but I will now show you how I easily get the query statement from MS Access.

(These screen shots were taken from Access 2000)



For a full example of the possibilities of this script, plus code that creates the database and populates_
it with data from the print server's event logs can be found here.
http://visualbasicscript.com/m_58935/tm.htm

Attachment (1)

< Message edited by TomRiddle -- 4/11/2008 10:02:28 PM >
 
 
Post #: 1
 
 RE: Query Access Database with VBScript - 4/11/2008 5:37:27 PM   
  ehvbs

 

Posts: 2064
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi TomRiddle,

thanks for the nice tutorial. One nit to pick:

This:
 
  WEND
  MyConn.close
  set RS = nothing

should be:                                                          or:

  WEND                                                              WEND
  RS.Close                                                          RS.Close
   MyConn.close                                                  set RS = nothing  ' optional
  set RS = nothing  ' optional                             MyConn.close
   set MyConn = nothing  ' optional                    set MyConn = nothing  ' optional

Regards

ehvbs

(in reply to TomRiddle)
 
 
Post #: 2
 
 RE: Query Access Database with VBScript - 4/11/2008 10:09:42 PM   
  TomRiddle


Posts: 165
Score: 4
Joined: 2/7/2008
Status: offline
Thanks for the tip ehvbs, I updated the original post.
Always learning.

(in reply to ehvbs)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript Tutorial >> Query Access Database with VBScript Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts