[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Javascript and ActiveX ADODB

Posted on 2006-05-11
7
Medium Priority
?
1,526 Views
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...).

Cheers
Verdy


// 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
   dbrcd.MoveNext();
}

</script>
0
Comment
Question by:verdante
  • 4
  • 3
7 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16671042
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?

Bob
0
 

Author Comment

by:verdante
ID: 16672164
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?

cheers

Verdy
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16672299
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?

Bob
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 96

Expert Comment

by:Bob Learned
ID: 16672308
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?

Bob
0
 

Author Comment

by:verdante
ID: 16688878
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.

cheers

Verdy
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 16760595
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
http://support.microsoft.com/?scid=kb;en-us;300699&spid=2509&sid=54

How to deploy data access pages over the Internet
http://support.microsoft.com/default.aspx?scid=KB;EN-US;264080

<Quote>
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.
</Quote>
0
 

Author Comment

by:verdante
ID: 16841186
TLO
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
Verdy
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…
Suggested Courses

872 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