如何在VB6.0里使用MSFlexGrid将Access中的数据导进来
SetConn=CreateObject("ADODB.Connection")SetReco=CreateObject("ADODB.Recordset")Conn.O...
Set Conn = CreateObject("ADODB.Connection")
Set Reco = CreateObject("ADODB.Recordset")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db1.mdb"
Reco.CursorLocation = adUseClient
Reco.Open "Select * From zhuhu ", Conn, 1, 1
怎么在写 在VB6.0里使用MSflexGrid将Access中的数据导进来
Public Sub writeMS(strSql As String, MS As MSFlexGrid)
'动态向网格中添加数据
Dim iC, iRow, iCol, i As Integer
Dim RS As New ADODB.Recordset
Dim iRows, iCols As Integer
iC = 0
Set RS = dbSelect(strSql)
iCols = RS.Fields.Count
MS.Cols = iCols
MS.Rows = 1
MS.Rows = 2
While Not RS.EOF
iC = iC + 1
For i = 0 To iCols - 1
MS.TextMatrix(iC, i) = RS.Fields(i)
Next i
MS.Rows = MS.Rows + 1
RS.MoveNext
Wend
For i = 0 To iCols - 1
MS.TextMatrix(0, i) = RS.Fields(i).Name
Next i
MS.TextMatrix(MS.Rows - 1, 0) = "合计:" & iC
Set RS = Nothing
End Sub 展开
Set Reco = CreateObject("ADODB.Recordset")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db1.mdb"
Reco.CursorLocation = adUseClient
Reco.Open "Select * From zhuhu ", Conn, 1, 1
怎么在写 在VB6.0里使用MSflexGrid将Access中的数据导进来
Public Sub writeMS(strSql As String, MS As MSFlexGrid)
'动态向网格中添加数据
Dim iC, iRow, iCol, i As Integer
Dim RS As New ADODB.Recordset
Dim iRows, iCols As Integer
iC = 0
Set RS = dbSelect(strSql)
iCols = RS.Fields.Count
MS.Cols = iCols
MS.Rows = 1
MS.Rows = 2
While Not RS.EOF
iC = iC + 1
For i = 0 To iCols - 1
MS.TextMatrix(iC, i) = RS.Fields(i)
Next i
MS.Rows = MS.Rows + 1
RS.MoveNext
Wend
For i = 0 To iCols - 1
MS.TextMatrix(0, i) = RS.Fields(i).Name
Next i
MS.TextMatrix(MS.Rows - 1, 0) = "合计:" & iC
Set RS = Nothing
End Sub 展开
1个回答
展开全部
何必搞得这么复杂,用MSHFlexGrid代瞎脊替MSFlexGrid
向毁握工程添加部件:microsoft hierarchical flexgrid control
然后用下面的代码同磨余渗样能达到要求:
Set Conn = CreateObject("ADODB.Connection")
Set Reco = CreateObject("ADODB.Recordset")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db1.mdb"
Reco.CursorLocation = adUseClient
Reco.Open "Select * From zhuhu ", Conn, 1, 1
set MSHFlexGrid1.DataSource=Reco
向毁握工程添加部件:microsoft hierarchical flexgrid control
然后用下面的代码同磨余渗样能达到要求:
Set Conn = CreateObject("ADODB.Connection")
Set Reco = CreateObject("ADODB.Recordset")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db1.mdb"
Reco.CursorLocation = adUseClient
Reco.Open "Select * From zhuhu ", Conn, 1, 1
set MSHFlexGrid1.DataSource=Reco
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询