我们正在使用NiceLabel Automation Builder –简单
我们有一个触发器,可以打开标签,设置打印机(通过变量),打印标签,然后执行vbscript,如下所示。
主要问题是使用标签变量[POC.ID]
,当我们尝试将其分配给adpar1Value
时,会出现以下错误。
应用程序对当前操作使用错误类型的值 在下面的代码行中。
set par1 =adoCmd.CreateParameter (adPar1Name, adPar1Type, adPar1Direction,4,adpar1Value)
但是,如果我们将值硬编码为adpar1Value,例如adpar1Value = “48”
并执行脚本,它可以按预期工作。
有人可以在代码行中提示错误吗?
有人可以建议在NiceLabel Automation Builder流程中捕获错误吗?
我们不确定在打印标签后[POC.ID]
是否在vbscript中保留其值。
'Function to query database and return xml string
Dim Part ' as StockCode Filter
Dim adoCmd ' As ADODB.Command
Dim adoConn ' As ADODB.adoConnection
Dim outStrm ' As ADODB.Stream
Dim txtResults ' String for results
Dim ConString ' String for adoConnection
Dim sQuery ' Query String
Dim fso ' File System Object
Dim ts ' Text Stream
Dim dbName ' The DNS name or IP address of your DB Server
Dim Catalog ' The specific database to adoConnect to
Dim TableName ' The table we will retrieve data from
Dim UID ' The User Name to login to your database (Not used)
Dim PWD ' The Password to login to your database (Not used)
'Connect to the database
'*******************************************************
Catalog = "DataWarehouse_XXXX"
'Set our server name
dbName = "OUR-SERVER"
ConString = "Provider=SQLOLEDB;Integrated Security=SSPI;Persist Security Info=False;" _
& "Initial Catalog=" & Catalog & ";Data Source=" & dbName & ";"
'msgbox (sadoConn)
Set adoConn = CreateObject("ADODB.Connection")
adoConn.ConnectionString = ConString
' adoConn.CursorLocation = 3
adoConn.Open
'Execute a stored procedure
'********************************************
'Create SQL Command Object
Set adoCmd = CreateObject("ADODB.Command" )
adoCmd.commandtype = 4 'To run store procedure
adoCmd.commandtext = "CHC_Labels.usp_UpdatePrinterStatus" 'stored procedure name
'Create Parameter object
dim par1, adpar1Value
Const adPar1Name="@ID"
Const adPar1Type=200 'For string see microsoft docs DataTypeEnum
Const adPar1Direction = 1 'For input see microsoft for ParameterDirectionEnum
'Const adPar1Size = 200 ' specifies the maximum length for the parameter value in characters or bytes.
adpar1Value = [POC.ID]
' Format Set parameter = command.CreateParameter (Name, Type, Direction, Size, Value)
set par1 =adoCmd.CreateParameter (adPar1Name,adPar1Type, adPar1Direction,4,adpar1Value)
'Add the parameter to the Command object
adoCmd.Parameters.Append par1
adoCmd.ActiveConnection = adoConn
adoCmd.Execute
'Cleanup Database objects
'*******************************************************
adoConn.Close
set adoConn = Nothing
set adoCmd = Nothing
set outStrm = Nothing