| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 597 人关注过本帖
标题:row自动增加行数 运行慢 还会死机
只看楼主 加入收藏
jsyyqyyq
Rank: 1
等 级:新手上路
帖 子:21
专家分:7
注 册:2011-12-21
结帖率:50%
收藏
已结贴  问题点数:20 回复次数:5 
row自动增加行数 运行慢 还会死机
我读取sql数据库 本来想做分页 没做出来 就想flex2.Rows = flex2.Rows + 1  一次查询有1万多条信息 运行慢 还会死机
谁有好一点的办法
搜索更多相关主题的帖子: sql数据库 办法 
2012-12-25 16:13
风吹过b
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:364
帖 子:4947
专家分:30084
注 册:2008-10-15
收藏
得分:20 
你是怎么分页的???

ASP 的代码,你参考一下。

'打开搜索 SQL 命令
rs.open sql,conn,1,1

'翻到当前页面,
    IF not IsNumeric(Request("page")) Or IsEmpty(Request("page")) Then        '读传入的 页数
      page=1            '没有,或不是数字,置为 1
    Else
      Page=Int(Abs(Request("page")))     '设置页数
    End if
if not rs.eof then   
    rs.pagesize = zts        '每页大小
    rs.absolutepage = page        '翻页
end if

        for i=1 to zts
                    if not rs.eof then
                             '读数据,显示数据


                  rs.movenext
                     else
                    exit for
                     end if
        next i

授人于鱼,不如授人于渔
早已停用QQ了
2012-12-25 16:56
jsyyqyyq
Rank: 1
等 级:新手上路
帖 子:21
专家分:7
注 册:2011-12-21
收藏
得分:0 
版主在吗  拜求指点了
Dim PageNow As Long
Dim PageMax As Long

Private Sub cmdfri_Click()
PageNow = 1
    Call flex2PullFY(flex2, ssql1, 6, PageNow)
    Call flex2PullFY(flex2, ssql2, 6, PageNow)
    Label1.Caption = "共" & PageMax & "页 当前是第 " & PageNow & " 页"
End Sub
'   分页显示内容
Private Sub cmdlas_Click()
PageNow = PageMax
     Call flex2PullFY(flex2, ssql1, 6, PageNow)
    Call flex2PullFY(flex2, ssql2, 6, PageNow)
    Label1.Caption = "共" & PageMax & "页 当前是第 " & PageNow & " 页"
End Sub

Private Sub cmdNext_Click()
If PageNow < PageMax Then
        PageNow = PageNow + 1
           Call flex2PullFY(flex2, ssql1, 6, PageNow)
           Call flex2PullFY(flex2, ssql2, 6, PageNow)
        Label1.Caption = "共" & PageMax & "页 当前是第 " & PageNow & " 页"
    Else
        MsgBox "超出范围"
End Sub
Private Sub cmdPre_Click()
 If PageNow > 1 Then
        PageNow = PageNow - 1
           Call flex2PullFY(flex2, ssql1, 6, PageNow)
           Call flex2PullFY(flex2, ssql2, 6, PageNow)
        Label1.Caption = "共" & PageMax & "页 当前是第 " & PageNow & " 页"
    Else
        MsgBox "超出范围"
    End If
End Sub
Private Sub Command2_Click()
    On Error GoTo 0
    Dim sPro, sSer, sCon, sDsn, DSNName
    Dim conn1, oRs1, oCom1, sSql1, m, conn2, oRs2, oCom2, sSql2
'     Dim conn1, oRs1, oCom1, sSql1, m,
    Dim oList, oItem, i, j
    Dim WinCC As Object
    Set WinCC = CreateObject("WinCC-Runtime-Project")
    Dim database
    database = WinCC.GetValue("@DatasourceNameRT")
    sPro = "Provider=WinCCOLEDBProvider.1;"
    sDsn = "Catalog= " & database & ";"
    sSer = "Data Source=.\WinCC;User ID=sa;"
    sCon = sPro & sDsn & sSer
    Text1.Text = DateAdd("h", -8, DTPicker1)
    Text2.Text = DateAdd("h", -8, DTPicker2)   
   sSql1 = "TAG:R,('PV\F1'),'" & Text1.Text & "','" & Text2.Text & "'"
   sSql2 = "TAG:R,('PV\F2'),'" & Text1.Text & "','" & Text2.Text & "'"
    Set conn1 = CreateObject("ADODB.Connection")
        conn1.ConnectionString = sCon
        conn1.CursorLocation = 3
        conn1.Open
    Set oRs1 = CreateObject("ADODB.Recordset")
    Set oCom1 = CreateObject(")
         = 1
    Set oCom1.ActiveConnection = conn1
         = sSql1
    Set oRs1 = oCom1.Execute
    Set conn2 = CreateObject("ADODB.Connection")
        conn2.ConnectionString = sCon
        conn2.CursorLocation = 3
        conn2.Open
    Set oRs2 = CreateObject("ADODB.Recordset")
    Set oCom2 = CreateObject(")
         = 1
    Set oCom2.ActiveConnection = conn2
         = sSql2
    Set oRs2 = oCom2.Execute
     flex2.Clear
    If (Not oRs1.EOF) Then
        oRs1.MoveFirst
        i = 1
           Do While Not oRs1.EOF
                flex2.TextMatrix(i, 1) = i
                flex2.TextMatrix(i, 2) = DateAdd("h", 8, oRs1.Fields(1).Value)
                flex2.TextMatrix(i, 3) = CStr(oRs1.Fields(2).Value)
                flex2.TextMatrix(i, 4) = CStr(oRs2.Fields(2).Value)
                oRs1.MoveNext
                oRs2.MoveNext
                i = i + 1
        Loop
            oRs1.Close
            oRs2.Close     
    End If

       Call flex2PullFY(flex2, ssql1, 6, PageNow)
       Call flex2PullFY(flex2, ssql2, 6, PageNow)
        PageNow = 1
        Label1.Caption = "共" & PageMax & "页 当前是第 " & PageNow & " 页"
   ConnectErr:
        flex2.Refresh


    Set oRs1 = Nothing
    Set oCom1 = Nothing
    Set conn1 = Nothing
    Set oRs2 = Nothing
    Set oCom2 = Nothing
    Set conn2 = Nothing
   
End Sub


Private Sub Form_Activate()

  flex2.Cols = 5

  '设置列标头。
  s$ = "^|^序号  |^        时间           |^       压力        |^     温度     "
  flex2.FormatString = s$
End Sub

'=====================================================================
'填充指定表单的内容MSFlexG表单名称,MYSQL查询语句,PageSize每页记录数,PageN显示指定页
Public Function flex2PullFY(flex2 As MSHFlexGrid, MYSQL As String, PageSize As Integer, PageN As Long)
    BooNull = False
    Dim Tmpi, Tmpj As Long
    '以下部分进行数据表打开操作===========================================
  
    sCon.Open MYSQL, sCon, adOpenKeyset, adLockReadOnly, adCmdText
    '=====================================================================
   
    '如果数据不为空,则进行读取操作=======================================
    '数据显示窗口的行数等于记录集记录数加上固定1行(数据名)==============
    '数据显示窗口的列数等于记录集表的数据项个数减去需要隐藏的数据项=======
    '(固定行默认是记录集中第一个字段)===================================
    If sCon.BOF And sCon.EOF Then
'        MsgBox "数据库中无符合条件的记录", , "提示"
        flex2.Clear
        flex2.Rows = 0
        flex2.Cols = 0
    Else
        sCon.PageSize = PageSize
        PageMax = sCon.PageCount
        sCon.MoveLast
        sCon.MoveFirst
        flex2.Rows = sCon.PageSize + 1
        flex2.Cols = sCon.PageSize + 1
     If sCon.RecordCount > 3000 Then MsgBox "读取数据量较大,请耐心等待", , "提示"
        sCon.AbsolutePage = PageN
        For Tmpi = 1 To sCon.PageSize
            flex2.TextMatrix(Tmpi, 0) = Str(Tmpi)
            For Tmpj = 1 To sCon.Fields.Count
                If IsNull(Trim(sCon.Fields(Tmpj - 1).Value)) Then        '控制填充内容不能为空
                    flex2.TextMatrix(Tmpi, Tmpj) = ""
                Else
                    flex2.TextMatrix(Tmpi, Tmpj) = Trim(sCon.Fields(Tmpj - 1).Value)
                End If
            Next Tmpj
            sCon.MoveNext
        Next Tmpi
        sCon.Close
        Set sCon = Nothing
    End If
    flex2.Refresh
     End Function

2012-12-26 13:42
jsyyqyyq
Rank: 1
等 级:新手上路
帖 子:21
专家分:7
注 册:2011-12-21
收藏
得分:0 
回复 2楼 风吹过b
在运行时 监控
 sCon.Open MYSQL, sCon, adOpenKeyset, adLockReadOnly, adCmdText
 MYSQL能看到连接   
sCon, adOpenKeyset, adLockReadOnly, adCmdText
度为空  这后面正常应为 1
我上面的程序那出了问题请指点下  
2012-12-26 13:45
风吹过b
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:364
帖 子:4947
专家分:30084
注 册:2008-10-15
收藏
得分:0 
没写过 MYSQL 的数据库程序,看静态代码无法分析到你的问题出在何处。

现在也没时间让我去装一个 MYSQL 来进行测试。。。。
年底事多

授人于鱼,不如授人于渔
早已停用QQ了
2012-12-26 15:50
jsyyqyyq
Rank: 1
等 级:新手上路
帖 子:21
专家分:7
注 册:2011-12-21
收藏
得分:0 
还有高手指点下吧
2012-12-27 11:11
快速回复:row自动增加行数 运行慢 还会死机
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018113 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved