Private Sub ShowData() Dim j As Integer 
Dim i As Integer 
Dim MsgText As String 
Set mrc = ExecuteSQL(txtSQL, MsgText) 
With msgList 
.Rows = 1 Do While Not mrc.EOF(此为调试错误地方) 
.Rows = .Rows + 1 
For i = 1 To mrc.Fields.Count 
If Not IsNull(Trim(mrc.Fields(i - 1))) Then 
Select Case mrc.Fields(i - 1).Type 
Case adDBDate 
.TextMatrix(.Rows - 1, i) = Format(mrc.Fields(i - 1) & "", "yyyy-mm-dd") 
Case Else 
.TextMatrix(.Rows - 1, i) = mrc.Fields(i - 1) & "" 
End Select 
End If 
Next i 
mrc.MoveNext 
Loop 
End With 
mrc.Close 
End Sub 
下面是executeSQL函数 
Public Function ExecuteSQL(ByVal SQL _ 
As String, MsgString As String) _ 
As ADODB.Recordset 
'executes SQL and returns Recordset 
Dim cnn As ADODB.Connection 
Dim rst As ADODB.Recordset 
Dim sTokens() As String On Error GoTo ExecuteSQL_Error sTokens = Split(SQL) 
Set cnn = New ADODB.Connection 
cnn.Open ConnectString 
If InStr("INSERT,DELETE,UPDATE,EXECUTE", _ 
UCase$(sTokens(0))) Then 
cnn.Execute (SQL) 
MsgString = sTokens(0) & _ 
" query successful" 
Else 
Set rst = New ADODB.Recordset 
rst.Open Trim$(SQL), cnn, _ 
adOpenKeyset, _ 
adLockOptimistic 
'rst.MoveLast 'get RecordCount 
Set ExecuteSQL = rst 
MsgString = "查询到" & rst.RecordCount & _ 
" 条记录 " 
End If 
ExecuteSQL_Exit: 
Set rst = Nothing 
Set cnn = Nothing 
Exit Function 
ExecuteSQL_Error: 
MsgString = "查询错误: " & _ 
Err.Description 
Resume ExecuteSQL_Exit 
End Function