Measurement Studio for .NET Languages

取消
显示结果 
搜索替代 
您的意思是: 

DataSocket in VBScript

I'm trying to use DataSocket in a VBScript to periodically post data updates to a DataSocket Server.  I'm getting errors when I try to set some of the public properties of the DataSocket.  The script is as follows:
 
dim oDS
set oDS = CreateObject("CWDSLib.CWDataSocket")
oDS.Url = "dstp://localhost/data"
oDS.AccessMode = Write
oDS.Connect
 
When I try to set the AccessMode property, I get the following error meesage: "Script control error: Value not in enumeration."  If this line is commented out, there are no other errors.  I've also had errors trying to access other attributes such as ConnectionStatus and IsConnected.
 
Does anyone have any suggestions?
0 项奖励
1 条消息(共 5 条)
4,514 次查看

The problem is that VBScript doesn't know what the Write value is. There are two ways that you can handle this. The first way is to define a constant for the value in your script and use your defined constant. The other way is to create a .wsf file and use the reference element to reference the type library so that the script recognizes the value. For example:

<job id="DataSocketExample">
    <reference object="CWDSLib.CWDataSocket" />
     
    <script language="vbscript">
    Dim ds
    Set ds = CreateObject("CWDSLib.CWDataSocket")
    ' Note that the value is cwdsWrite, not Write
    ds.AccessMode = cwdsWrite
    MsgBox ds.AccessMode
    </script>
</job>

- Elton

0 项奖励
2 条消息(共 5 条)
4,501 次查看
Thanks, Elton.  I decided to go with declaring a constant in my situation.  From information that I found in the Knowlegde Base, I've concluded that the values to use to set the AccessMode property are as follows:
 
2 = Read
3 = ReadAutoUpdate
4 = Write
5 = WriteAutoUpdate
 
Is this correct?
 
 
0 项奖励
3 条消息(共 5 条)
4,493 次查看

Yes.

- Elton

0 项奖励
4 条消息(共 5 条)
4,485 次查看

I'm having trouble posting data from my script to the DataSocket Server.  I used an example project from the web site that contained a DataSocket reader and writer to do a quick test of the DataSocket Server, and it works O.K.  However, when I try run my script, I don't see data updates on the reader(which is set up in the ReadAutoUpdate mode).

The script is called by a third party application to post a data update, and it runs rather infrequently (maybe every 10 to 15 minutes).  The script basically reads a block of data (ot type double) from the application's database into an array, and attempts to post this array to the DataSocket server.  The attached code segment shows the key parts of the script.  Am I setting up the DataSocket Write operation correctly?

0 项奖励
5 条消息(共 5 条)
4,471 次查看