Javascript and ActiveX ADODB

Posted on 2006-05-11
Last Modified: 2010-05-19
Hi JS junkies. Yeah alright lame intro but it's late here. I am attempting to access a local data source thru javascript and ActiveX. I have modified some code I found in another EE question and I'm pleased to say it works locally (http://localhost/...). But when I try it from my remote web location it does nothing. I get all the appropriate security messages from the local site then the code executes,  but I get no security messages when loading in my browser from my remote website.

I'm a bit new to this level of complexity with javascript. My remote site uses ASP vbscript and this file is written in ASP javascript. I've created a new little test site for it locally and have just attempted to copy it to the remote website that uses ASP vbscript. Is this language variation the killer? If so, any solutions? Or is it something in the code (see below...).


// Create ADO Recordset
var dbrcd = new ActiveXObject( "ADODB.Recordset" );

// Create the connection string
var cString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = c:/folder/database.mdb;Persist Security Info=false";

// Create SQL Statement
var sql = "SELECT * FROM Clienttable";

// Open connection to database
dbrcd.Open( sql, cString, 1, 3 );

// Loop through all the records found
while( !dbrcd.EOF )
   // variable to store data
   record = "";
   // Loop through each field in this record
  // and add contents to variable
  // Starting field set to 1 to skip record id field. Use 0 for all fields
   for( i = 1; i < dbrcd.Fields.Count; i++ )
       record += dbrcd(i) + "\n";
   // Display the contents in Popup
   alert( record );
   //Move to the next record and loop

Question by:verdante
    LVL 96

    Expert Comment

    by:Bob Learned
    1) Where is the remote site located?  

    2) What is the site running on?  IIS?  Apache?

    3) You aren't getting any Javascript error warnings from the browser?

    4) Browser type, version?

    5) Are you able to debug this code?


    Author Comment

    Thanks TLO

    I twigged on your suggestion about Javascript errors . I wasn't receiving any errors so I decided to check my IE settings ( I do generally). I selected the IE setting to display a notification about all script errors and I received the following error:

    "ADODB.Recordset:Safety Settings on this computer prohibit accessing a data source on another domain".

    If the logic of that message is correct that would be an error from the server but that doesn't make much sense because the data is still just sitting in workstation memory prior to server-side scripting to write it to the database. So I've checked the remainder of my security settings in IE but can't find anything relating to domains. Is it likely to be a fiewall setting? I use McAfee. Off the top of your head, from your vast experience with .NET, is there a way I can make this domain trusted?


    LVL 96

    Expert Comment

    by:Bob Learned
    1) Is the database on the same machine as the web server?

    2) Is there a reason why you are using Access, instead of something like SQL Server Express 2005?

    LVL 96

    Expert Comment

    by:Bob Learned
    3) You are trying to get to the Access database from client-side code.

    4) Weren't you saying something about ASP.NET, so do you also have a classic ASP project also?


    Author Comment

    Sorry TLO, I've been away for a few days. Answers to questions:

    1. On the test machine the database is on the same machine as the web server. However that is not true of the remote site.

    2. No reason why I'm using Access. Could just as easily use SQL Server in fact I probably should have gone down that path as a number of our clients have data sources within MSDE.

    3. / 4. We have .NET application with a centralised database. We are wanting to consume data from client sites however we are aware at present that a number of these sites do not have web servers least of all web services to enable us to consume their data. One option we are exploring is how we might be able to use ActiveX with Javascript to connect to client data sources while they are online and populate web forms with those values. I can now do this locally on my test machine and I'm now trying to transfer this technology to our website. The latest obstacle I am trying to overcome is accessing data sources from other domains.

    I know this is anything but a typical method of data sharing but it would be a very, very handy solution prior to web services becoming available on all client machines.


    LVL 96

    Accepted Solution

    1) Security issues and settings abound in remote configurations that don't exist locally, so all that makes sense.

    2) Here are some possibilities:

    Common data access page deployment Errors;en-us;300699&spid=2509&sid=54

    How to deploy data access pages over the Internet;EN-US;264080

    Additional Configuration Settings for Windows Server 2003
    You must apply the following configuration settings, or you may receive the following error message:

    Error: Safety settings on this computer prohibit accessing a data source on another domain.
    1. Click Start, point to All Programs, point to Administrative Tools, and then click Internet Information Services (IIS) Manager.
    2. Expand WebServer (local computer) (where WebServer is the actual computer name that is assigned to your Web server), and then expand Web Server Extensions.
    3. Click the Add a new Web service extension hyperlink.
    4. When the New Web Service Extension dialog box appears, enter MSADC in the Extension name box, and then click Add.
    5. When the Add file dialog box appears, type C:\Program Files\Common Files\System\msadc\msadcs.dll, and then click OK.
    6. Click to select the Set extension status to Allowed check box, and then click OK.
    7. Close IIS Manager.

    Author Comment

    Thx a heap. The emails regarding the deletion of the other leader question prompted me to finish my testing. I had to install a cut down version of OWC on the server (as it did not have MS Office) to read the data access page but it worked!
    Nice outcome

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    In my daily work (mainly using, I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
    Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now