I tried to run a script to get value from a table. First check if record exists if yes then extract the customer name. Below is the script I use.
Script Use:
'Get Customer Name from Customer List based on Customer Number extracted
CustomerNumber = Watch.GetVariable("CustomerNumber")
dim sqlread
DB_CONNECT_STRING = Watch.GetVariable("global.DB_CONNECT_STRING")
Set myConn = CreateObject("ADODB.Connection")
myConn.Open DB_CONNECT_STRING
Set rs = CreateObject("ADODB.Recordset")
sqlread ="SELECT Count(\*) as NoOfRec ,(\[Customer_Name\])"&\_
" FROM \[TheCat13\]"&\_
" WHERE \[Customer_Number\] = '"&\_
""&CustomerNumber&"'"&\_
"GROUP BY \[Customer_Name\]"
rs.Open sqlread, myConn
if rs.fields("NoOfRec") = 1 then
'Exists
CustomerName = rs.fields("Customer_Name")
else
CustomerName ="Not Found"
end if
rs.Close
watch.setVariable "CustomerName",CustomerName
Watch.Log "Customer Name is "& watch.getVariable ("CustomerName"),3
Error :
\[0014\] W3602 : Error 0 on line 19, column 1: :
\[0014\] W3603 : Error running script.
Please advise where went wrong.