PDA

View Full Version : Microsoft Access Connection


Beck
03-08-2003, 04:43 AM
The following chunk of VB Code is tested and totally runs on IE6+ on my local machine when there are no spaces in the database's directory. My question for the magic eight ball is, is there a JavaScript Equivalent? If so, does anyone either know it or know how I can go about researching (aka copy/pasting) it?

Thanks.

The VB Code:

path=Mid(Left(document.location,InStrRev(document.location, "/")) & "H6.mdb", 9)
' prewritten vbscript, courtesy of Dr. John
Dim rsH6 ' global recordset name
Dim objConn ' global connection object
Const adOpenKeyset = 1 ' ADO constants
Const adOpenDynamic = 2
Const adLockPessimistic = 2
Dim Conn ' connection string
Dim Query ' query string
set objConn = CreateObject("ADODB.Connection")
set rsH6 = CreateObject("ADODB.Recordset")
Conn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Trim(path) & ";"
objConn.open Conn ' open connection
rsH6.CursorType = adOpenKeyset ' set cursor type
rsH6.LockType = adLockPessimistic ' set lock type

' list h6 sites in select form element for user selections
Query = "SELECT SiteID, SiteName, Address FROM H6" ' set the query to h6 sites
rsH6.open Query, objConn ' get record set from query
Do While Not rsH6.EOF ' loop through query
Set ObjEntry = document.createElement("OPTION") ' place each h6 site in select
objEntry.Text = rsH6.fields("SiteName") ' element for user access
objEntry.Value = rsH6.fields("SiteID")
selSites.Add objEntry
rsH6.MoveNext ' next h6 site
Loop
rsH6.close ' close query of h6 sites

' open access to user information in the database and prepare for login
'Query = "INSERT INTO [User] (UserID,PW,Role,SiteID) VALUES ('bob','bobpw','U','H02')"
Query = "SELECT UserID, SiteID, PW FROM [User]" ' set the query to users
rsH6.open Query, objConn ' get record set from query

Beck
03-08-2003, 04:45 AM
did I spell tack right? Hm...

I have one more thought to add to my quesiton: like mentioned, this only appears to run on my local machine, and does not work on my free webpage server. Does anyone know a free webpage service provider where this kind of access would be successful? Does it require a CGI bin or some kind of SQL service?

Thanks.

Spookster
03-08-2003, 04:21 PM
Well first of all javascript cannot do any of that. Second of all VBscript is typically used in ASP(Active Server Page) applications so of course you will need a host that supports ASP and some kind of database system such as MSSQL or MySQL.

Beck
03-08-2003, 10:57 PM
Thanks for the infos, Spookster. Too bad, I had my heart set on it, too! :p