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.OLE DB.4.0;Dat a
Source=D:\sites\username\_ db\databas e.mdb;Pers ist
Security Info=False
Thanks in advance.
Provider=Microsoft.Jet.OLE
Source=D:\sites\username\_
Security Info=False
Thanks in advance.
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\dat abases\"
dbPath = curDir & "mydb.mdb"
StrConnect = "Provider=Microsoft.Jet.OL EDB.4.0;Da ta Source =" & dbPath & ";Persist Security Info=False"
Set Conn = CreateObject("ADODB.Connec tion")
Conn.Open StrConnect
set rs = CreateObject("ADODB.Record set")
SQLStr = "Select * from myTable "
Rs.Open SQLStr, conn, 1, 1
...
Hope this helps
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\dat
dbPath = curDir & "mydb.mdb"
StrConnect = "Provider=Microsoft.Jet.OL
Set Conn = CreateObject("ADODB.Connec
Conn.Open StrConnect
set rs = CreateObject("ADODB.Record
SQLStr = "Select * from myTable "
Rs.Open SQLStr, conn, 1, 1
...
Hope this helps
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
and the other scripts will be similar between ASP and VBscrpt.
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 .CONNECTIO N")
Set objRs = Server.CreateObject("ADODB .RECORDSET ")
objCn.ConnectionString = "Provider=Microsoft.Jet.OL EDB.4.0;Da ta Source=D:\sites\username\_ db\databas e.mdb;Pers ist Security Info=False"
objCn.Open
objRs.ActiveConnection=obj Cn
and substitude the D:\sites\username\_db\data base.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")
Dim objCn 'ADODB Connection object
Dim objRs 'ADODB Recordset object
Set objCn = Server.CreateObject("ADODB
Set objRs = Server.CreateObject("ADODB
objCn.ConnectionString = "Provider=Microsoft.Jet.OL
objCn.Open
objRs.ActiveConnection=obj
and substitude the D:\sites\username\_db\data
if the database is stored in a directory under your 'home directory' on the server, use
Server.MapPath("path from your home folder")
I could'nt understand what you want exactly.
Thanks,
Sachi