wincc中的vba、数据库问题

已锁定

xthuaqiang

  • 帖子

    41
  • 精华

    0
  • 被关注

    1

论坛等级:游士

注册时间:2008-03-02

普通 普通 如何晋级?

wincc中的vba、数据库问题

873

3

2008-07-07 19:37:24

求助WINCC的VBA的问题

显示记录
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
Dim amMSHFlexGrid
Dim pstr
Dim pds
Dim psi
Dim sCon
Dim sSql
Dim conn
Dim oRs
Dim oCom
Dim m
Dim kstr
Dim ispl
Dim i,j
Dim tagcxr,tagcxy,tagcxn
Set amMSHFlexGrid=ScreenItems("mMSHFlexGrid")
Set tagcxn = HMIRuntime.Tags("i_value5")
Set tagcxy = HMIRuntime.Tags("i_value1")
Set tagcxr = HMIRuntime.Tags("i_value2")
amMSHFlexGrid.ColWidth(0)=900
amMSHFlexGrid.TextMatrix(0,0)="H"
amMSHFlexGrid.ColWidth(25)=665
amMSHFlexGrid.TextMatrix(0,25)="1班"
amMSHFlexGrid.ColWidth(26)=665
amMSHFlexGrid.TextMatrix(0,26)="2班"
amMSHFlexGrid.ColWidth(27)=665
amMSHFlexGrid.TextMatrix(0,27)="3班"
For i=1 To 24
amMSHFlexGrid.ColWidth(i)=665
amMSHFlexGrid.TextMatrix(0,i)=i-1 &"H"
Next
For j=1 To 42
amMSHFlexGrid.TextMatrix(j,0)=j-1
Next
pstr="Provider=Microsoft.Jet.OLEDB.4.0;"
pds="Data Source=E:\shulushuju.mdb;"
psi="Persist Security Info=False"
sSql="select * from slbaobiao where trim(slbaobiao.nian) ="
sSql=sSql & tagcxn.Read & " " & "and" & " trim(slbaobiao.yue) ="
sSql=sSql & tagcxy.Read & " " & "and" & " trim(slbaobiao.ri) = "
sSql=sSql & tagcxr.Read & " " & "order by slbaobiao.ri,slbaobiao.shi,slbaobiao.fen"
sCon=pstr & pds &psi
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 =sSql
Set oRs = oCom.Execute
m = oRs.RecordCount
Set amMSHFlexGrid=ScreenItems("mMSHFlexGrid")
amMSHFlexGrid.Clear
oRs.movefirst
amMSHFlexGrid.TextMatrix(0,0)= oRs.Fields("nian") & "-" & oRs.Fields("yue") & "-" & oRs.Fields("ri")
For i=1 To m
''wendu
amMSHFlexGrid.TextMatrix(0,i)=oRs.Fields("yue") & "-" & oRs.Fields("ri") & ":" & oRs.Fields("shi") & ":" & oRs.Fields("fen")
amMSHFlexGrid.TextMatrix(1,i)=oRs.Fields("t_ranshaoshi1")
amMSHFlexGrid.TextMatrix(2,i)=oRs.Fields("t_ranshaoshi2")
amMSHFlexGrid.TextMatrix(3,i)=oRs.Fields("t_ranshaoshi3")
amMSHFlexGrid.TextMatrix(4,i)=oRs.Fields("t_ranshaoshi4")
amMSHFlexGrid.TextMatrix(5,i)=oRs.Fields("t_hunqishi1")
amMSHFlexGrid.TextMatrix(6,i)=oRs.Fields("t_hunqishi2")
amMSHFlexGrid.TextMatrix(7,i)=oRs.Fields("t_hunqishi3")
amMSHFlexGrid.TextMatrix(8,i)=oRs.Fields("t_hunqishi4")
amMSHFlexGrid.TextMatrix(9,i)=oRs.Fields("t_ganzaodai1")
amMSHFlexGrid.TextMatrix(10,i)=oRs.Fields("t_ganzaodai2")
amMSHFlexGrid.TextMatrix(11,i)=oRs.Fields("t_ganzaodai3")
amMSHFlexGrid.TextMatrix(12,i)=oRs.Fields("t_ganzaodai4")
amMSHFlexGrid.TextMatrix(13,i)=oRs.Fields("t_beishaodai1")
amMSHFlexGrid.TextMatrix(14,i)=oRs.Fields("t_beishaodai2")
amMSHFlexGrid.TextMatrix(15,i)=oRs.Fields("t_beishaodai3")
amMSHFlexGrid.TextMatrix(16,i)=oRs.Fields("t_beishaodai4")
amMSHFlexGrid.TextMatrix(17,i)=oRs.Fields("t_junredai1")
amMSHFlexGrid.TextMatrix(18,i)=oRs.Fields("t_junredai2")
amMSHFlexGrid.TextMatrix(19,i)=oRs.Fields("t_junredai3")
amMSHFlexGrid.TextMatrix(20,i)=oRs.Fields("t_junredai4")
amMSHFlexGrid.TextMatrix(21,i)=oRs.Fields("t_lengquedai1")
amMSHFlexGrid.TextMatrix(22,i)=oRs.Fields("t_lengquedai2")
amMSHFlexGrid.TextMatrix(23,i)=oRs.Fields("t_lengquedai3")
amMSHFlexGrid.TextMatrix(24,i)=oRs.Fields("t_lengquedai4")
amMSHFlexGrid.TextMatrix(25,i)=oRs.Fields("t_hongganchuang1")
amMSHFlexGrid.TextMatrix(26,i)=oRs.Fields("t_hongganchuang2")
amMSHFlexGrid.TextMatrix(27,i)=oRs.Fields("t_daofengqiang1")
amMSHFlexGrid.TextMatrix(28,i)=oRs.Fields("t_daofengqiang2")
amMSHFlexGrid.TextMatrix(29,i)=oRs.Fields("t_pailiao1")
amMSHFlexGrid.TextMatrix(30,i)=oRs.Fields("t_pailiao2")
amMSHFlexGrid.TextMatrix(31,i)=oRs.Fields("t_yanzhao")
''yali
amMSHFlexGrid.TextMatrix(32,i)=oRs.Fields("p_zhuranfeng")
amMSHFlexGrid.TextMatrix(33,i)=oRs.Fields("p_lengfeng")
amMSHFlexGrid.TextMatrix(34,i)=oRs.Fields("p_meiqi")
amMSHFlexGrid.TextMatrix(35,i)=oRs.Fields("p_ranshaoshi1")
amMSHFlexGrid.TextMatrix(36,i)=oRs.Fields("p_ranshaoshi2")
''liuliang
amMSHFlexGrid.TextMatrix(37,i)=oRs.Fields("f_zhuranfeng1")
amMSHFlexGrid.TextMatrix(38,i)=oRs.Fields("f_zhuranfeng2")
amMSHFlexGrid.TextMatrix(39,i)=oRs.Fields("f_meiqi1")
amMSHFlexGrid.TextMatrix(40,i)=oRs.Fields("f_meiqi2")
amMSHFlexGrid.TextMatrix(41,i)=oRs.Fields("f_lengfeng")
amMSHFlexGrid.TextMatrix(42,i)=oRs.Fields("f_sq")
oRs.Movenext
Next
oCom.cancel
Set oCom=Nothing
oRs.close
Set oRs=Nothing
conn.close
Set conn=Nothing
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
添加记录
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
Dim pstr,pds,psi,ispl,sSql,sCon
Dim conn
Dim oRs
Dim oCom
Dim Atag1,Atag2,Atag3,Atag4,Atag5,Atag6,Atag7,Atag8,Atag9,Atag10,Atagshi,Atagfen,Atagyue
Dim Atag11,Atag12,Atag13,Atag14,Atag15,Atag16,Atag17,Atag18,Atag19,Atag20,Atagnian,Atagri
Dim Atag21,Atag22,Atag23,Atag24,Atag25,Atag26,Atag27,Atag28,Atag29,Atag30,Atag42
Dim Atag31,Atag32,Atag33,Atag34,Atag35,Atag36,Atag37,Atag38,Atag39,Atag40,Atag41
Set Atagnian = HMIRuntime.Tags("snian")
Set Atagyue = HMIRuntime.Tags("syue")
Set Atagri= HMIRuntime.Tags("sri")
Set Atagshi = HMIRuntime.Tags("sshi")
Set Atagfen = HMIRuntime.Tags("sfen")
Set Atag1 = HMIRuntime.Tags("i_value")
''t_ranshaoshi1
Set Atag2 = HMIRuntime.Tags("i_value")
''t_ranshaoshi2
Set Atag3 = HMIRuntime.Tags("i_value")
''t_ranshaoshi3
Set Atag4= HMIRuntime.Tags("i_value")
''t_ranshaoshi4
Set Atag5 = HMIRuntime.Tags("i_value")
''t_hunqishi1
Set Atag6 = HMIRuntime.Tags("i_value")
''t_hunqishi2
Set Atag7 = HMIRuntime.Tags("i_value")
''t_hunqishi3
Set Atag8 = HMIRuntime.Tags("i_value")
''t_hunqishi4
Set Atag9= HMIRuntime.Tags("i_value")
''t_ganzaodai1
Set Atag10 = HMIRuntime.Tags("i_value")
''t_ganzaodai2
Set Atag11 = HMIRuntime.Tags("i_value")
''t_ganzaodai3
Set Atag12 = HMIRuntime.Tags("i_value")
''t_ganzaodai4
Set Atag13 = HMIRuntime.Tags("i_value")
''t_beishaodai1
Set Atag14 = HMIRuntime.Tags("i_value")
''t_beishaodai2
Set Atag15 = HMIRuntime.Tags("i_value")
''t_beishaodai3
Set Atag16 = HMIRuntime.Tags("i_value")
''t_beishaodai4
Set Atag17 = HMIRuntime.Tags("i_value")
''t_junredai1
Set Atag18 = HMIRuntime.Tags("i_value")
''t_junredai2
Set Atag19 = HMIRuntime.Tags("i_value")
''t_junredai3
Set Atag20 = HMIRuntime.Tags("i_value")
''t_junredai4
Set Atag21 = HMIRuntime.Tags("i_value")
''t_lengquedai1
Set Atag22 = HMIRuntime.Tags("i_value")
''t_lengquedai2
Set Atag23 = HMIRuntime.Tags("i_value")
''t_lengquedai3
Set Atag24= HMIRuntime.Tags("i_value")
''t_lengquedai4
Set Atag25 = HMIRuntime.Tags("i_value")
''t_hongganchuang1
Set Atag26 = HMIRuntime.Tags("i_value")
''t_hongganchuang2
Set Atag27 = HMIRuntime.Tags("i_value")
''t_daofengqiang1
Set Atag28 = HMIRuntime.Tags("i_value")
''t_daofengqiang2
Set Atag29= HMIRuntime.Tags("i_value")
''t_pailiao1
Set Atag30 = HMIRuntime.Tags("i_value")
''t_pailiao2
Set Atag31 = HMIRuntime.Tags("i_value")
''t_yanzhao
Set Atag32 = HMIRuntime.Tags("i_value")
''p_zhuranfeng
Set Atag33 = HMIRuntime.Tags("i_value")
''p_lengfeng
Set Atag34= HMIRuntime.Tags("i_value")
''p_meiqi
Set Atag35 = HMIRuntime.Tags("i_value")
''p_ranshaoshi1
Set Atag36 = HMIRuntime.Tags("i_value")
''p_ranshaoshi2
Set Atag37 = HMIRuntime.Tags("i_value")
''f_zhuranfeng1
Set Atag38 = HMIRuntime.Tags("i_value")
''f_zhuranfeng2
Set Atag39= HMIRuntime.Tags("i_value")
''f_meiqi1
Set Atag40 = HMIRuntime.Tags("i_value")
''f_meiqi2
Set Atag41 = HMIRuntime.Tags("i_value")
''f_lengfeng
Set Atag42 = HMIRuntime.Tags("i_value")
pstr="Provider=Microsoft.Jet.OLEDB.4.0;"
pds="Data Source=E:\shulushuju.mdb;"
psi="Persist Security Info=False"
ispl="insert into slbaobiao("
ispl=ispl & "nian,yue,ri,shi,fen,"
ispl=ispl & "t_ranshaoshi1,t_ranshaoshi2,t_ranshaoshi3,t_ranshaoshi4,"
ispl=ispl & "t_hunqishi1,t_hunqishi2,t_hunqishi3,t_hunqishi4,"
ispl=ispl & "t_ganzaodai1,t_ganzaodai2,t_ganzaodai3,t_ganzaodai4,"
ispl=ispl & "t_beishaodai1,t_beishaodai2,t_beishaodai3,t_beishaodai4,"
ispl=ispl & "t_junredai1,t_junredai2,t_junredai3,t_junredai4,"
ispl=ispl & "t_lengquedai1,t_lengquedai2,t_lengquedai3,t_lengquedai4,"
ispl=ispl & "t_hongganchuang1,t_hongganchuang2,"
ispl=ispl & "t_daofengqiang1,t_daofengqiang2,"
ispl=ispl & "t_pailiao1,t_pailiao2,t_yanzhao,"
ispl=ispl & "p_zhuranfeng,p_lengfeng,p_meiqi,"
ispl=ispl & "p_ranshaoshi1,p_ranshaoshi2,"
ispl=ispl & "f_zhuranfeng1,f_zhuranfeng2,f_meiqi1,f_meiqi2,f_lengfeng,f_sq"
ispl=ispl & ")values("
ispl=ispl & Atagnian.Read & "," & Atagyue.Read & "," & Atagri.Read & "," & Atagshi.Read & "," & Atagfen.Read & ","
ispl=ispl & Atag1.Read & ","& Atag2.Read & "," & Atag3.Read & "," & Atag4.Read & ","
ispl=ispl & Atag5.Read & "," & Atag6.Read & "," & Atag7.Read & "," & Atag8.Read & ","
ispl=ispl & Atag9.Read & "," & Atag10.Read & "," & Atag11.Read & "," & Atag12.Read & ","
ispl=ispl & Atag13.Read & "," & Atag14.Read & "," & Atag15.Read & "," & Atag16.Read & ","
ispl=ispl & Atag17.Read & "," & Atag18.Read & "," & Atag19.Read & "," & Atag20.Read & ","
ispl=ispl & Atag21.Read & "," & Atag22.Read & "," & Atag23.Read & ","& Atag24.Read & ","
ispl=ispl & Atag25.Read & ","& Atag26.Read & "," & Atag27.Read & "," & Atag28.Read & ","
ispl=ispl & Atag29.Read & ","& Atag30.Read & "," & Atag31.Read & "," & Atag32.Read & ","
ispl=ispl & Atag33.Read & "," & Atag34.Read & "," & Atag35.Read & ","& Atag36.Read & ","
ispl=ispl & Atag37.Read & "," & Atag38.Read & ","
ispl=ispl & Atag39.Read & ","& Atag40.Read & "," & Atag41.Read & "," & Atag42.Read
ispl=ispl & ")"
sCon=pstr & pds & psi
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 = ispl
Set oRs = oCom.Execute
oCom.cancel
Set oCom=Nothing
oRs.close
Set oRs=Nothing
conn.close
Set conn=Nothing
几次使用显示记录后退出时有时出现如下错误:
1、使用去激活时,Graphic Design runtime 到11%不能退出。
2、unhandled exception was raised,look file "c:\program files\siemens\wincc\diagnose\PDLRTSEH.log"
3、pdlrt.exe产生错误,会被windows关闭,您需要从新启动程序。
4、并且确认以后,有时过一会错误消失,可以从新启动。
不知是何原因,望各位专家指教,在此非常感谢!!!
wincc中的vba、数据库问题 已锁定
编辑推荐: 关闭

请填写推广理由:

本版热门话题

SIMATIC WinCC / Panel

共有32564条技术帖

相关推荐

热门标签

相关帖子推荐

guzhang

恭喜,你发布的帖子

评为精华帖!

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

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

  • 分享

  • 只看
    楼主

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