用ADODC连接数据库,用for循环对数据库循环查询,每次都会取得一个值,怎么把每次取得的值放在MSHFlexGrid中,并且下一个值放到下一行呢?我现在是直接用set MSHFlexGrid。datasource=adodc1 这样只能显示一个值啊

解决方案 »

  1.   

    with mshflexgrid
        for i=1 to adodc1.recordset.recordcount
            .rows=.rows+1
            .textmatrix(.rows-1,0)=adodc1.recordset!aa
            .textmatrix(.rows-1,1)=adodc1.recordset!bb
            ...
            adodc1.recordset.movenext
        next i
    end with
      

  2.   

    adodc1.recordset!aa
    这个aa是什么啊?
      

  3.   

    呃 不知道怎么用···
    For i = 1 To Adodc1.Recordset.RecordCount
    Text5.Text = MSHFlexGrid1.TextMatrix(i, 9) * 2                                
    intP = MSHFlexGrid1.TextMatrix(i, 6) \ 256
         Select Case intP
            Case 0
                Text3.Text = "map_1"                                             
                Text4.Text = MSHFlexGrid1.TextMatrix(i, 6) * 2                     
            Case 1
                Text3.Text = "map_2"
                Text4.Text = (MSHFlexGrid1.TextMatrix(i, 6) - 256) * 2 + 1
            Case 2
                Text3.Text = "map_3"
                Text4.Text = (MSHFlexGrid1.TextMatrix(i, 6) - 512) * 2 + 1
            Case 3
                Text3.Text = "map_4"
                Text4.Text = (MSHFlexGrid1.TextMatrix(i, 6) - 768) * 2 + 1
            Case 4
                Text3.Text = "map_5"
                Text4.Text = (MSHFlexGrid1.TextMatrix(i, 6) - 1024) * 2 + 1
            Case 5
                Text3.Text = "map_6"
                Text4.Text = (MSHFlexGrid1.TextMatrix(i, 6) - 1280) * 2 + 1
            Case 6
                Text3.Text = "map_7"
                Text4.Text = (MSHFlexGrid1.TextMatrix(i, 6) - 1536) * 2 + 1
            Case Else
                Text3.Text = "map_8"
                Text4.Text = (MSHFlexGrid1.TextMatrix(i, 6) - 1792) * 2 + 1
            
    End Select
    Me.MSHFlexGrid2.FormatString = "     |PROD_ID|OPNAME|VALUE|DATATYPE|RESULT "   
    MSHFlexGrid2.Rows = i + 1                                                       MSHFlexGrid2.TextMatrix(i, 1) = MSHFlexGrid1.TextMatrix(i, 2)
    MSHFlexGrid2.TextMatrix(i, 2) = MSHFlexGrid1.TextMatrix(i, 3)
    MSHFlexGrid2.TextMatrix(i, 3) = MSHFlexGrid1.TextMatrix(i, 9)
    MSHFlexGrid2.TextMatrix(i, 4) = MSHFlexGrid1.TextMatrix(i, 8)Adodc2.ConnectionString = "driver={SQL Server};" & "server=user-PC;uid=sa;pwd=lenovo;database=nc863db"
    Adodc2.RecordSource = "select substring(" & Text3.Text & "," & Text4.Text & "," & Text5.Text & ") from p_map where progressive= '" & Text1.Text & "'"
    要将Adodc2中的值依次赋给MSHFlexGrid2.TextMatrix(i, 5)该咋做啊?
      

  4.   

    For i = 1 To Adodc1.Recordset.RecordCountMSHFlexGrid2.TextMatrix(i, 5)=adodc2.recordset.fields(0).value
    adodc2.recordset.movenext试一下这个思路