VBScript Action insert to SQL

Viewed 0

Dear readers,

We are trying to use the VBscript Action to insert some details into a SQL after which we can automaticlly generate a support ticket. But it seems my best days of VBscriptin is over and i keep having an issue.

 Const adOpenStatic = 3
Const adLockOptimistic = 3

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

objConnection.Open _
    "Provider=SQLOLEDB;Data Source=nlvensq01;" & _
        "Trusted_Connection=Yes;Initial Catalog=Synergy;" & _
             "User ID=pentair\svc_admin;Password=Blabla;"

objConnection.Execute "INSERT INTO dbo.Servermonitoring(Datum, Computer, Monitortype, Title, Details) VALUES (Date, Machine, MonitorType, MonitorTitle, Details)"

The code used can be seen above. This gives the error that Date is not a correct Syntax (But its the variable used by PA Monitor) If i replease the VALUES string with (Clear text instead of the PA Variables)

VALUES ('31-10-2012', 'Machine', 'MonitorType', 'MonitorTitle', 'Details')

Basiclly this script runs everytime a monitor is in error for 5 minutes and inserts Date string, Machine name Monitor type, MonitorTitle and the Error Details to a SQL table which is being used by our Workflow tool. it inserts what i want it to. Can anyone advise on what i am doing wrong in this case?

Regards, Mike Sternfeld

1 Answers

I think you probably need to change it to:

VALUES ('" + Date + "', '" + Machine + "', '" + MonitorType + "', '" + MonitorTitle + "', '" + Details + "')"

Related