INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Accessing an Access database in JavaScript - Classic ASP

Accessing an Access database in JavaScript - Classic ASP

(OP)
I have a front end written using classic ASP. One of its elements is a select/option drop-down menu using Onchange. As such the user will scroll through a bunch of database records, no problem at all using ASP. When the Onchange fires it causes a function, a *JavaScript* function, in the header to be executed. I have no problem constructing the appropriate SQL statement in the form of
"select * where ID=value"

How do I open the desired database (XYZ.MDB, for example) and execute the constructed SQL upon it, all in JavaScript?

(Oh, the database resides on a remote server, protected by a userID/password)

RE: Accessing an Access database in JavaScript - Classic ASP

Quote:

How do I open the desired database (XYZ.MDB, for example) and execute the constructed SQL upon it, all in JavaScript?

You can't.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

RE: Accessing an Access database in JavaScript - Classic ASP

(OP)
That's succinct! Definitive?

RE: Accessing an Access database in JavaScript - Classic ASP

You cannot directly access a database server with javascript, simple as that.

Your choices are:
  • round trip to the server and construct a query, display the results
  • call an ASP url with AJAX, display the results.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

RE: Accessing an Access database in JavaScript - Classic ASP

As mentioned in the sql server forum you posted in, the only way to do it is with an AJAX call. So, yes the Chris' answer is definitive, you cannot access a database or any server using pure javascript.
what you have to do is use javascript(I suggest using the JQuery framework), to make an AJAX call. This in turn runs code on the server by way of a POST or GET. From there you return an object back (usually a serialized JSON object, as they are the easiest to work with in my experience)

Although it may seem complicated, I would look at the JQuery site and they have many examples to get you started. Once you do it, you will see it is not very hard to do at all.
Take a look here to get you started: http://api.jquery.com/jquery.ajax/

RE: Accessing an Access database in JavaScript - Classic ASP

You could also use javascript to submit the form in the ONCHANGE event and handle things that way, but that can be awkward as the page will refresh each time a different option is selected

RE: Accessing an Access database in JavaScript - Classic ASP

I see now, what I said above is basically the first of ChrisHirst's two suggestions.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close