Public Sub FillMsGrid(ByVal MSGrid As MSFlexGridLib.AxMSFlexGrid, ByVal rs As ADODB.Recordset) '数据库全部填充到表格中
Dim rCount As Integer
Dim i As Integer
Dim j As Integer
Dim cCount As Integer
cCount = rs.Fields.Count
rCount = rs.recordcount
With MSGrid
'设置行数
If rCount = 0 Then
.Rows = 1
Else
.Rows = rCount + 1
End If
'设置列数
.Cols = cCount
'设置固定列的名及对齐方式
For i = 0 To cCount - 1
.set_ColAlignment(i, 1)
.set_TextMatrix(0, i, rs(i).Name)
Next
'将数据库中的数据导入到表格中
j = 1
Do While Not rs.EOF
For i = 0 To cCount - 1
.set_TextMatrix(j, i, CStr(rs(i).Value))
Next
rs.MoveNext()
j = j + 1
Loop
End With
End Sub
Public Rs As New ADODB.Recordset
Public Conn As New ADODB.Connection
Public Sub Make_Connection()
Dim strConn As String
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\People.mdb;Persist Security Info=False"