Using SQL with VBA in Excel

在利用ADO+SQL查询ACCESS数据库

VB中是这样的
?:任意单个字符 如LIKE ‘?南’ ,LIKE ‘?南?’
*:零个或多个字符 如:LIKE ‘*南’ , LIKE ‘*南*’

而在VBA中则不能这样用,它的用法竟然和SQL查询SQL Server数据库的语法一致:
_ :任意单个字符 如LIKE ‘_南’ ,LIKE ‘_南_’
%:零个或多个字符 如:LIKE ‘%南’ , LIKE ‘%南%’

Read the rest of this entry »

Some useful SQL for OLEDB

Get snapshot for all tags

SELECT tag, time, value, DIGSTRING(status) AS status FROM piarchive..pisnapshot

Get data for a digital tag

SELECT tag, time, DIGSTRING(CAST(value AS Int32)) AS value, DIGSTRING(status) AS status
FROM piarchive..picomp2
WHERE tag = 'cdm158' AND time >= 't'

Read the rest of this entry »

map在PI接口开发中的应用

(1) PI数据接口开发时瓶颈

在PI数据接口的开发中,最主要的一个数据结构就是包含与该接口相关的测点及其属性的一个列表,还有对该表中测点元素的查找、插入和删除等基本的操作。同时,较高的性能要求使得必须对该测点表进行一定的排序,对表中元素的访问也需要相应的搜索算法。

而在具体实现数据接口的时,由于数据源的多样性,导致列表排序及搜索的关键字以及数据采集的模式不尽相同,因此曾经在用C实现数据接口时,常需要为每一个或每一类数据源实现一套测点的链接表结构,并配以各自的搜索和排序算法。这样,大多的开发时间消耗在底层数据结构的实现和调试上,而且代码的复用率低。于是,高效的、通用性高的数据结构及实现方式的选择成为当务之急。

Read the rest of this entry »

Using PI SDK with Visual Basic 6.0

osi.jpg

PI SDK References for a VB Project
PISDK 1.3 Type Library
Main PI SDK dynamic link library (DLL) – primary library for PI SDK content
PI-SDK Dialogs Library
Contains standard PI SDK functions like tag search and connection handling
PISDKCommon 1.0 Type Library
Makes available some shared data structures, like “named values”
PITimeServer 1.1 Type Library
Parses time strings and correctly renders time in several useful forms
PISDKParse 1.1 Type Library
Handles parsing / interpreting of expressions for the PI SDK – including PI PE style filter and calculation expressions

Read the rest of this entry »