|
大神,我有问题咨询。
Public Sub Allrecordset_in_RD()
Dim Con As ADODB.Connection
Dim Rec As ADODB.Recordset
Dim iRowscount As Long
Set Con = New ADODB.Connection
Con.ConnectionString = "DRIVER={MySQL ODBC 5.2 Unicode Driver};Server=111.1.1.1;Port=3306;Database=xxx;UID=a;PWD=a;OPTION=3;Stmt=Set Names 'GBK';"
Dim sqlString As String
sqlString = "select * from t_program_update_autoapp_rd where qc_num_ like '%acv%'"
Con.Open
Set Rec = New Recordset
Set Rec = Con.Execute(sqlString, iRowscount, adCmdText)
Range("a1:ag1").Value = Array("pid", "no_", "qc_num_", "explain_", "module_", "developer_", "careful_", "release_domain_", "actual_version_", "ess_bss_", "code_file_", "tag_num_", "cvs_version_", "cvs_history_version_", "deposit_path_", "remarks_", "time_", "userid_", "code_code_", "source_", "insert_type_", "a4", "a5", "update_time_", "conflict_solve_info_", "beijing", "shandong", "heilongjiang", "hebei", "henan", "liaoning", "harvest", "modify_type_")
'显示标题行
Range("a2").CopyFromRecordset Rec
Rec.Close: Set Rec = Nothing
Con.Close: Set Con = Nothing
MsgBox "显示 " & iRowscount & " 行", vbOKOnly, ""
'显示查询记录
End Sub
为啥展现出的结果的行数正确(9行),A列的值正确(9行),但是其他列的值都是空白的?sql语句在数据库查询是正确的。
如果在Range("a2").CopyFromRecordset Rec加断点的话,就能显示第一行的完整数据,但是其他行还是不行。 |
|