工控编程吧

标题: WINCC查询SQL的数据 [打印本页]

作者: baikhgmv    时间: 2016-9-8 11:17
标题: WINCC查询SQL的数据
WINCC查询SQL的数据

WINCC 查询数据库有几句代码不知道什么意思帮忙解释一下 最好每一句话都解释一下  非常感谢

Dim conn                     '定义类对象

Dim SCon                     '定义数据库连接字符串

Dim oRs

Dim oCom

Dim oRs1

Dim oRs2

Dim m

Dim strSQL                  '定义SQL执行语句

Dim strSQL2

Dim olist

'建立连接

Set conn=CreateObject("ADODB.Connection")

    conn.ConnectionString = sCon

    conn.CursorLocation = 3  

    conn.Open

'使用命令文本进行查询

Set oRs = CreateObject("ADODB.Recordset")

Set oCom = CreateObject("ADODB.Command")

    oCom.CommandType = 1

Set oCom.ActiveConnection = conn

    oCom.CommandText = strSQL

    '填充记录集

Set oRs1 = oCom.Execute

    m = oRs1.RecordCount


    oCom.CommandText = strSQL2

Set oRs2 = oCom.Execute


Set oRs1 = Nothing

Set oRs2 = Nothing

Set oCom = Nothing

conn.Close

Set conn = Nothing

MsgBox "查询到+'"&M&"'+条数据,     提示"


------这是查询数据库中表记录的VBS代码。

数据库、表、记录集。必须了解数据库知识。


---------现在基本了解大概的意思了,谢谢








欢迎光临 工控编程吧 (https://www.gkbc8.com/) Powered by Discuz! X3.4