发表于:2006/3/12 13:58:00
#0楼
根据《深入浅出wincc 6.0》那本书里面的教程,在p231页中的set ors = ocom.execute始终没有办法执行通过,很想问一下到底是什么原因。
很多天没有解决的问题,希望各位帮助
下面是程序,内部变量等已经定义了,SQL数据库名字也没有问题,就不说了,就是set ors = ocom.execute执行不过去
Dim spro 'As String
Dim sdsn 'As String
Dim sser 'As String
Dim scon 'As String
Dim ssql 'As String
Dim conn 'As Object
Dim ors 'As Object
Dim ocom 'As Object
Dim oitem 'As listitem
Dim m, n, s
spro = "provider = WinCCOLEDBProvider.1;"
sdsn = "catalog = cc_test#new_06_03_10_13_51_24r;"
sser = "data source = .\wincc"
scon = spro + sdsn + sser
ssql = "tag: r,'PVarchive\tag1','0000-00-00 00:00:10','0000-00-00 00:00:00'"
'MsgBox "open with:" & vbCr & vbCr & scon & vbCr & vbCr & ssql & vbCr
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.fields.count
Dim listview1
Set listview1 = ScreenItems("listview1")
listview1.columnheaders.clear
listview1.columnheaders.add , , CStr(ors.fields(1).name),140
listview1.columnheaders.add , , CStr(ors.fields(2).name),70
listview1.columnheaders.add , , CStr(ors.fields(3).name),70
If(m>0) Then
ors.movefirst
n = 0
Do While Not ors.eof
n = n+1
s = Left(CStr(ors.fields(1).value),23)
Set oitem = listview1.listitems.add()
oitem.text = Left(CStr(ors.fields(1).value),23)
oitem.subitems(1) = FormatNumber(ors.fields(2).value,4)
oitem.subitems(2) = Hex(ors.fields(3).value)
If(n>1000) Then Exit Do
ors.movenext
Loop
ors.close
Else
End If
Set ors = Nothing
conn.close
Set conn = Nothing
很多天没有解决的问题,希望各位帮助
下面是程序,内部变量等已经定义了,SQL数据库名字也没有问题,就不说了,就是set ors = ocom.execute执行不过去
Dim spro 'As String
Dim sdsn 'As String
Dim sser 'As String
Dim scon 'As String
Dim ssql 'As String
Dim conn 'As Object
Dim ors 'As Object
Dim ocom 'As Object
Dim oitem 'As listitem
Dim m, n, s
spro = "provider = WinCCOLEDBProvider.1;"
sdsn = "catalog = cc_test#new_06_03_10_13_51_24r;"
sser = "data source = .\wincc"
scon = spro + sdsn + sser
ssql = "tag: r,'PVarchive\tag1','0000-00-00 00:00:10','0000-00-00 00:00:00'"
'MsgBox "open with:" & vbCr & vbCr & scon & vbCr & vbCr & ssql & vbCr
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.fields.count
Dim listview1
Set listview1 = ScreenItems("listview1")
listview1.columnheaders.clear
listview1.columnheaders.add , , CStr(ors.fields(1).name),140
listview1.columnheaders.add , , CStr(ors.fields(2).name),70
listview1.columnheaders.add , , CStr(ors.fields(3).name),70
If(m>0) Then
ors.movefirst
n = 0
Do While Not ors.eof
n = n+1
s = Left(CStr(ors.fields(1).value),23)
Set oitem = listview1.listitems.add()
oitem.text = Left(CStr(ors.fields(1).value),23)
oitem.subitems(1) = FormatNumber(ors.fields(2).value,4)
oitem.subitems(2) = Hex(ors.fields(3).value)
If(n>1000) Then Exit Do
ors.movenext
Loop
ors.close
Else
End If
Set ors = Nothing
conn.close
Set conn = Nothing