WinCC V7.2 数据库连接问题请教

已锁定

xiaode

  • 帖子

    1411
  • 精华

    2
  • 被关注

    49

论坛等级:奇侠

注册时间:2008-07-18

钻石 钻石 如何晋级?

WinCC V7.2 数据库连接问题请教

3926

11

2015-09-02 10:02:40

 我这边电脑安装了WinCC V7.2 版本, 在自带的SQLServer 中建立了一个数据库,并且在电脑的ODBC 的用户DSN 和系统DSN中,都添加了该数据库,并在添加的时候,测试连接成功。我在脚本中编了程序,用来查询,但是不成功,具体的程序如下:

Dim A_AirTest_Pro

Dim cn

Dim rst

Dim rstCom

Dim strcn

Dim objItem

Dim strsql

 

A_AirTest_Pro= HMIRuntime.Tags("Air_Program_No_01").Read

 

 

HMIRuntime.Tags("Air_Fill_Time_01").Write 0.0

HMIRuntime.Tags("Air_Steady_Time_01").Write 0.0

HMIRuntime.Tags("Air_Check_Time_01").Write 0.0

 

HMIRuntime.Tags("Air_Fill_Press_01").Write 0.0

HMIRuntime.Tags("Air_Steady_Press_01").Write 0.0

HMIRuntime.Tags("Air_Check_Press_01").Write 0.0

 

HMIRuntime.Tags("Air_Process").Write "Data Read Finsh"

 

 'strcn = "Data Source=Test_01;UID='';PWD='';"

strcn = "Data Source=Test_01;UID=shc30053;PWD=shc30053;"

Set cn = CreateObject("ADODB.connection")

 

cn.ConnectionString = strcn

cn.Open

 

HMIRuntime.Tags("Air_Process").Write "Sql Server connection"

 

strsql = "SELECT * FROM Air_Leak_Test Where Program_No ="&A_AirTest_Pro&""

HMIRuntime.Tags("Air_Process").Write "Sql Server connection_01"

 

Set rst = CreateObject("ADODB.Recordset")

HMIRuntime.Tags("Air_Process").Write "Sql Server connection_02"

 

Set rstCom = CreateObject("ADODB.Command")

HMIRuntime.Tags("Air_Process").Write "Sql Server connection_03"

 

rstCom.CommandType=1

HMIRuntime.Tags("Air_Process").Write "Sql Server connection_04"

 

Set rstCom.ActiveConnection = cn

HMIRuntime.Tags("Air_Process").Write "Sql Server connection_05"

 

rstCom.CommandText = strsql

HMIRuntime.Tags("Air_Process").Write "Sql Server connection_06"

 

Set rst = rstCom.Execute

'rstCom.Execute

 

HMIRuntime.Tags("Air_Process").Write "Sql command execute"

 

If Not rst.eof Then

rst.MoveFirst

HMIRuntime.Tags("Air_Fill_Time_01").Write rst.Fields(0).value

HMIRuntime.Tags("Air_Steady_Time_01").Write rst.Fields(1).value

HMIRuntime.Tags("Air_Check_Time_01").Write rst.Fields(2).value

 

HMIRuntime.Tags("Air_Fill_Press_01").Write rst.Fields(3).value

HMIRuntime.Tags("Air_Steady_Press_01").Write rst.Fields(4).value

HMIRuntime.Tags("Air_Check_Press_01").Write rst.Fields(5).value

 

End If

 

 

rst.close

cn.close

Set rst=Nothing

Set cn=Nothing

程序走到

Set rst = rstCom.Execute 这里不走了,也就是说,该语句并没有执行。但是以上的代码在WinCC V7.0 中是可以执行的。不知道为什么在7.2 中就执行不下去。希望大家帮忙解答一下。多谢了!

二者的区别,我看了一下,7.0 装在32位的操作系统Win7 企业版 SP1 .7.2 装在64位的操作系统Win7 企业版SP1。

 


WinCC V7.2 数据库连接问题请教 已锁定
编辑推荐: 关闭

请填写推广理由:

本版热门话题

SIMATIC WinCC / Panel

共有32913条技术帖

相关推荐

热门标签

相关帖子推荐

guzhang

恭喜,你发布的帖子

评为精华帖!

快扫描右侧二维码晒一晒吧!

再发帖或跟帖交流2条,就能晋升VIP啦!开启更多专属权限!

  • 分享

  • 只看
    楼主

top
X 图片
您收到0封站内信:
×
×
信息提示
很抱歉!您所访问的页面不存在,或网址发生了变化,请稍后再试。