views:

85

answers:

2

Hi All,

I'm need to know can i connect db through javascript? Actually, the last action where i end is done through javacsript. Now, i need to make some entries(extracted through javascript) in the database where last action stops. How can this be done?

Khushi

+1  A: 

The answer depends on where the Javascript being run.

If you're asking about Javascript running in a browser directly accessing a database on a remote server then the answer is no. The best you can do is create a web service which updates the Database and call that via an XMLHTTPRequest object from you JavaScript. You would need to be very careful about what you offered via such a web service. If you allowed any SQL statements anybody could connect to your service and run DELETE FROM customer; or insert new user records or do anything ghastly.

If you're running JavaScript through the Windows Scripting Host via CSCRIPT.EXE or similar you can create ODBC objects and access the database that way.

If you're running JavaScript on a JVM I think you can use JDBC.

If you want to give more details I can be more specific.

Dave Webb
A: 

Hi Dave,

Can u tell me more specific on Windows Scripting Host via CSCRIPT.EXE or similar?

My problem is, I wanna implement code in javaScript/Vbscript to access mySql database.