YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

how to create dataset in PB by VBA Options · View
chautran123
#1 Posted : Wednesday, May 19, 2010 8:42:10 AM
Rank: Newbie
Groups: Member

Joined: 5/19/2010
Posts: 8
Location: hanoi
i have been try to make a dataset with type pbDatasetExpression in vba

Code:

Dim Application As Object
Dim MyDatasets As Datasets
Dim MyDataset As Dataset

Set MyDatasets = Application.Datasets
MyDataset = MyDatasets.Add("NewCalcDataSet", NULL, TRUE, 1, TRUE, pbDatasetExpression)

MyDataset.Expression = "'sinusoid'*2"
MyDataset.RefreshInterval = 3600

But my program alway show error : object required
can you help me!
Sponsor  
 

OSIsoft vCampus is a subscription-based, online offering that consists of providing everything people need to develop applications on the PI System.
We invite you to take a "tour" of the OSIsoft Virtual Campus - also feel free to consult the FAQ  or contact OSIsoft vCampus for more details.
RJK Solutions
#2 Posted : Wednesday, May 19, 2010 9:00:28 AM
Rank: Administration

Groups: Administration

Joined: 6/20/2008
Posts: 612
Location: Cheshire, United Kingdom.
Welcome to the forum.

Couple of typo's in your code.

Use "Nothing" instead of "NULL".
Use "pbDatasetPIExpression" instead of "pbDatasetExpression".
Get the Datasets from the Display level object "ThisDisplay".

Use Get/Set for Datasets to modify them.

Example:

Code:

Dim MyDatasets As Datasets
Set MyDatasets = ThisDisplay.Datasets

Dim MyDataset As PIExpressionDataset
Set MyDataset = MyDatasets.Add("NewCalcDataSet", Nothing, True, 1, True, pbDatasetPIExpression)
Set MyDataset = MyDatasets.GetDataset("NewCalcDataSet")

MyDataset.ServerName = "localhost"
MyDataset.Expression = "'sinusoid'*2"
MyDataset.RefreshInterval = 3600
MyDataset.ColumnName = "Value"
MyDataset.Interval = "10m"

MyDatasets.SetDataset MyDataset
Principal Consultant
Real-Time Data Management @ Wipro Technologies
chautran123
#3 Posted : Wednesday, May 19, 2010 9:09:50 AM
Rank: Newbie
Groups: Member

Joined: 5/19/2010
Posts: 8
Location: hanoi
i have try your code and it is ok
thank you verymuch BigGrin
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.