Online Forums
Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.
Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.
Do not use the Contact page for technical issues.
How to use EasyOpcLib in SQLCLR
I got confused because your questions are in the QuickOPC.NET forums (yes I understand, because SQLCLR is a .NET host), but from our perspective, it is QuickOPC-COM product and component that you are using.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
We do not have dedicated methods to check the validity. But there are specific error codes returned in such cases. You already know the error code for an invalid OPC server class . Then, there are two such errors for invalid OPC items: One is when the syntax is totally invalid, and one is when the syntax is valid but still the item does not exist. The codes for this are:
//
// MessageId: OPC_E_UNKNOWNITEMID
//
// MessageText:
//
// The item ID is not defined in the server address space or no longer exists in the server address space.
//
#define OPC_E_UNKNOWNITEMID ((HRESULT)0xC0040007L)
//
// MessageId: OPC_E_INVALIDITEMID
//
// MessageText:
//
// The item ID does not conform to the server's syntax.
//
#define OPC_E_INVALIDITEMID ((HRESULT)0xC0040008L)
Why do you want to specifically test these? (because there are other kind of errors that can also cause failures). Also note that the component does re-tries automatically (this is mainly relevant with subscriptions; if you pass in an invalid info, it may become valid, such as in case of server reconfiguration; but you do not have to put in the retrial logic, it's all handled internally by QuickOPC).
Please Log in or Create an account to join the conversation.
What is the best way to check for an OPC server or an item name that does not exist?
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Kind regards,
Zbynek Zahradnik
Please Log in or Create an account to join the conversation.
I am trying to create a user-defined-function that I can call from a SQL stored procedure. The code for the function is as follows:
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.SqlTypes
Imports Microsoft.SqlServer.Server
Imports OpcLabs.Interop.EasyOpcLib
Partial Public Class UserDefinedFunctions
_
Public Shared Function ReadTrends() As Single
Dim opc As New EasyDAClient
Dim valu As Single
valu = opc.ReadItemValue("", "OPCLabs.Kiterver.2", "Trends.Ramp (1 s)")
Return valu
End Function
End Class
When I attempt to call the function from SQL I get the following error:
A .NET Framework error occurred during execution of user-defined routine or aggregate "ReadTrends":
System.Runtime.InteropServices.COMException: Invalid class string
System.Runtime.InteropServices.COMException:
at OpcLabs.Interop.EasyOpcLib.EasyDAClientClass.ReadItemValue(Object varMachineName, Object varServerClass, Object varItemId, Object varDataType, Object varAccessPath)
at OxyOPCAssembly.UserDefinedFunctions.ReadTrends()
Can anyone help me with this? Thank you.
Please Log in or Create an account to join the conversation.