我在数据库中读取过程值归档时总出现的错误! 点击:605 | 回复:0



fengle

    
  • 精华:0帖
  • 求助:0帖
  • 帖子:44帖 | 85回
  • 年度积分:0
  • 历史总积分:267
  • 注册:2007年8月30日
发表于:2007-09-14 10:31:00
楼主
我要实现的就是在一个窗体中,放入一个按钮控件和一个vlistview控件 当按钮点击时。Listview中显示 出在数据库中查询出来的 过程值归档的数据。但每次运行时都出下面图片中的这个提示框。
    我曾用这段代码把连接字符串改为 ODBC 连接查我自己的建立数据库。能够显示数据


我的代码如下,
  Dim sPro   
    Dim sDsn    
    Dim sSer    
    Dim sCon    
    Dim sSql    
    Dim conn    
    Dim oRs    
    Dim oCom    
    Dim oItem    
    Dim m,s,n,i
    Dim Control
   sPro="provider=WinCCOLEDBProvider.1;"
   sDsn="Catalg=CC_wincc_sq_07_09_06_10_08_26R;"
   sSer="Data Source=ZHANGJIGANG\WINCC"
      sCon=sPro+sDsn+sSer
      [color=#008000]'sPro="provider=MSDASQL;"  /////////////////////////////////  ODBC  的连接
     'sDsn="DSN=CC_wincc_sq_07_09_06_10_08_26R;"
      'sSer="UID= PWD= "
    ' sSql="select * from archive"[/color]   sSql="TAG:R,1,'0000-00-00 00:10:00.000','2007-09-13 13:13:00.000'"
   MsgBox"Open with:"&vbCr &sCon &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
   MsgBox"1:"
   m=oRs.Fields.Count
    Set Control=ScreenItems("ListView1")
    Control.View=3   
   ''''''''''''''''''''''''''''''控制列头 名
    Control.ColumnHeaders.Clear
     For s=0 To m-1 Step 1
     If s=0 Or s=1 Then 
     Control.ColumnHeaders.add, ,CStr(oRs.Fields(s).Name),200
     Else
     Control.ColumnHeaders.add, ,CStr(oRs.Fields(s).Name),70
     End If
     Next
 ''''''''''''''''''''''''''''
   If(m>0) Then
     oRs.MoveFirst
      n=0
      
     Do While Not oRs.EOF
     n=n+1
     Set oItem=Control.ListItems.Add()
&nbs


热门招聘
相关主题

官方公众号

智造工程师