View Single Post
  #2 (permalink)  
Old September 7th, 2005, 05:40 PM
philip_cole philip_cole is offline
Friend of Wrox
Points: 894, Level: 11
Points: 894, Level: 11 Points: 894, Level: 11 Points: 894, Level: 11
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Sep 2005
Location: London, , United Kingdom.
Posts: 166
Thanks: 2
Thanked 33 Times in 33 Posts

Hi Panuvin,

Server is only used in ASP, and isnt available in javascript. Also, if this is normal client-side javascript, the database would have to be on the local computer. I dont know if you can read access databases across the web.

To convert to javascript, you dont have to change much, mainly just defining constants and creating ActiveXObjects instead of using Server:

adOpenForwardOnly = 0;
adLockReadOnly = 1;
adCmdText = 1;

var myConnect = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=db\\sdi.mdb";

var ConnectObj = new ActiveXObject("ADODB.Connection");
var RS = new ActiveXObject("ADODB.Recordset");
var sql = "SELECT * FROM Categories;";

RS.Open(sql, ConnectObj, adOpenForwardOnly,adLockReadOnly,adCmdText);

var recordCount = RS.Fields.Count;
alert ("recordCount: " + recordCount);

Hope this helps
Philip Cole
Reply With Quote