Link to home
Start Free TrialLog in
Avatar of trickstar
trickstar

asked on

Convert this code from Javascript to VBscript

I have a problem with some code provided by my hosting company - my asp pages are all in VBScript and the code provided isn't.  If someone could give me a simple translation that would be great.


Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=D:\sites\username\_db\database.mdb;Persist
Security Info=False

Thanks in advance.
Avatar of sachiek
sachiek
Flag of Singapore image

Can you put full code?
I could'nt understand what you want exactly.

Thanks,
Sachi
Avatar of Ryan Chong
Hi trickstar,

The code you posted above will be part of the vbscript already.

Try define a connection? try using the ADO Data Object:

example.vbs:

curDir = "E:\myfolder\myproject\databases\"
dbPath = curDir & "mydb.mdb"

StrConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source =" & dbPath & ";Persist Security Info=False"

Set Conn = CreateObject("ADODB.Connection")
Conn.Open StrConnect

set rs = CreateObject("ADODB.Recordset")
SQLStr = "Select * from myTable "
Rs.Open SQLStr, conn, 1, 1

...

Hope this helps
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
and the other scripts will be similar between ASP and VBscrpt.
Avatar of Siriuss
Siriuss

The 'code' u supplied is the just value of the connection string. So all you really need to add is something like

Dim objCn      'ADODB Connection object
Dim objRs      'ADODB Recordset object

Set objCn = Server.CreateObject("ADODB.CONNECTION")
Set objRs = Server.CreateObject("ADODB.RECORDSET")
objCn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\sites\username\_db\database.mdb;Persist Security Info=False"

objCn.Open
objRs.ActiveConnection=objCn  

and substitude the D:\sites\username\_db\database.mdb with the path of the database.

if the database is stored in a directory under your 'home directory' on the server, use

Server.MapPath("path from your home folder")