IMPORTANT ANNOUNCEMENT

These forums were permanently set to read-only mode on July 20, 2022. From that day onwards, no new posting or comment is allowed on the site, but the historical content remains intact and searchable.

A new location for posting questions about PlanetPress Suite is now available:

OL Learn - PlanetPress Classic (opens in new tab)

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
window.location='automaticInsert.php?var1=z_testingonly&var2=PO&var3=7';

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

Thanks

Top
#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: 1984
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

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


Hi,

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

Code:
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)")
MyConn.Close
Set MyConn = Nothing  
Hope this helps
Maxime

Top