I need to translate this JScript to VBScript.
Can someone help me please ?
<script language=VBScript RunAt=Server>
function Disconnect(objRS)
set objRS.ActiveConnection = nothing
end function
</script>
<script language=JScript RunAt=Server>
function TreeCount(objRSCats, objRSLinks, intID){
var
arrSons, intLinks = 0, i;
objRSCats.Filter = 'PARENT_ID = ' + intID;
if (!objRSCats.EOF){
arrSons = new VBArray(objRSCats.GetRows(adGetRowsRest, adBookmarkFirst, 'CAT_ID')).toArray();
for (i = 0; i < arrSons.length; i++)
intLinks += TreeCount(objRSCats, objRSLinks, arrSons[i]);
}
objRSLinks.Filter = 'LINK_CAT_ID = ' + intID;
intLinks += objRSLinks.RecordCount;
if (intID > 0){
objRSCats.Filter = 'CAT_ID = ' + intID;
objRSCats.Update('LinkCount', intLinks);
}
return intLinks;
}
function Dump(objRS){
objRS.Filter = adFilterNone;
Response.Write(objRS.GetString(2, -1, ', ', '<br>', ''));
}
function Calc(){
var
strCon, strSQL, objCon, objRSCats, objRSLinks;
strCon = 'Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=E:\\SERVER\\WWWROOT\\tdnod\\db\\test.mdb';
objCon = Server.CreateObject('ADODB.Connection');
objCon.Open(strCon);
strSQL = 'SELECT CAT_ID, CAT_NAME, PARENT_ID, CAT_ID AS LinkCount FROM CATS';
objRSCats = Server.CreateObject('ADODB.Recordset');
objRSCats.CursorType = adUseClient;
objRSCats.CursorLocation = adOpenStatic;
objRSCats.LockType = adLockOptimistic;
objRSCats.Open(strSQL, objCon);
objRSCats(0).Properties('Optimize') = true;
objRSCats(2).Properties('Optimize') = true;
Disconnect(objRSCats);
strSQL = 'SELECT LINK_ID, LINK_NAME, LINK_CAT_ID FROM LINKS';
objRSLinks = Server.CreateObject('ADODB.Recordset');
objRSLinks.CursorType = adUseClient;
objRSLinks.CursorLocation = adOpenStatic;
objRSLinks.LockType = adLockReadOnly;
objRSLinks.Open(strSQL, objCon);
objRSLinks(2).Properties('Optimize') = true;
Disconnect(objRSLinks);
TreeCount(objRSCats, objRSLinks, 0);
Dump(objRSCats);
objRSCats.Close();
objRSLinks.Close();
objCon.Close();
}
</script>