ygalipeau

PI OLEDB performance in .Net

Discussion created by ygalipeau on Jan 1, 2010
Latest reply on Jan 4, 2010 by cescamilla

Happy new year everyone!

 

i am doing a test with pioledb in a vb.net app. Basically i am extracting 100 time a value from the snapshot (just to test the OLEDB performance). to extract 100 times a value from the snapshot, it always take 6-7 seconds. is this the performance i should expect from PIoledb or there is something i am doing wrong? Also i know for this particular case here i could do it differently, but what i want to know is if there are settings or other .NET tricks i could use to speed the code below.

 

here is my code:

Private Sub GetSnapshot_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GetSnapshot.Click

        Dim connString As String = "Provider=PIOLEDB.1;Data Source=ITWKS14;User ID = piadmin;password = ''" 
        Dim myConnection As OleDbConnection
        myConnection = New OleDbConnection(connString)

        myConnection.Open()
        Dim i As Int32
        Try

            For i = 0 To 100
                'construct the command object and open a connection to the table
                Dim cmdString As String = "Select value from piarchive..pisnapshot where tag = 'CDT158'"

                ''Create OleDbCommand object
                Dim TheCommand As OleDbCommand = New OleDbCommand(cmdString, myConnection)
                TheCommand.CommandType = CommandType.Text


                '' Create a DataReader and call Execute on the Command Object to construct it
                Dim TheDataReader As OleDbDataReader = TheCommand.ExecuteReader()


                Do While TheDataReader.Read()
                    TheDataReader.GetValue(0).ToString()
                Loop

                TheDataReader.Close()
            Next

        Catch ae As OleDbException
            Dim file As New IO.StreamWriter("c:\PI Engine.log", True)
            file.WriteLine(ae.Source)
            file.WriteLine(ae.Message)
            file.Close()
            file.Dispose()
            file = Nothing

        End Try
       
    End Sub

thanks

 

yannick galipeau

 

 

Outcomes