Topic Options
#19080 - 01/31/08 01:08 PM Java or VB script to insert data in a database
Maxime Laforest Offline
Junior Member

Registered: 12/18/07
Posts: 1
Loc: Montreal
I am trying to write some javascript to call a PHP program ans passing variables from the Watch process. The php program connects to my database and executes the inserts. No it all works well when I execute the script out of Planet Press. But when I run the process I get an error stating Microsoft Jscript runtime error:'window' is undefined.

Here is the 1 line code

I need help and/or some sample code to insert into a database.


#19081 - 01/31/08 03:25 PM Re: Java or VB script to insert data in a database
Philippe F. Offline
OL Expert

Registered: 09/06/00
Posts: 1941
Loc: Objectif Lune, Montreal, Qc
The Window object in JScript is declared by the Windows Scripting Host (WSH) or by Internet Explorer. This is why your script runs correctly outside of PlanetPress Watch (because double-clicking on a .js file implicitely launches WSH or some other system-defined scripting engine to execute your script).

However, PlanetPress Watch itself does not use the WSH and therefore does not provide the JS code with the Window object (nor with any other Scripting Engine-specific objects). By the same token, the WSH does not provide a standard JS script with access to the native PPWatch functions and properties. These are mutually exclusive.

There may be methods available to create - from within the JScript you're writing - an instance of the WSH object and use that instance to obtain a reference to the Window object, but that is way beyond the scope of this forum.
Technical Product Manager
I don't want to achieve immortality through my work; I want to achieve immortality through not dying - Woody Allen

#19082 - 01/31/08 04:04 PM Re: Java or VB script to insert data in a database


Here is a quick example using VB Script in the run script action of PlanetPress Watch/Server:

Dim MyConn, SQL
Set MyConn=CreateObject("ADODB.Connection")
MyConn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=C:\Database.mdb;"
MyConn.Execute( "INSERT INTO test  (field) values (5)")
Set MyConn = Nothing  
Hope this helps