|
rantional robot脚本,我用ADO的方式访问数据库,然后取得结果的数据保存为Excel文件,结果却发生说某对象的方法返回值不支持数据类型,就是下面红色那句话产生异常
对应oracle数据库中该字段为number类型
请大哥们解决下,谢谢
Function CompareDatas(strCondition As String, strTableName As String, Optional strFieldName) As Integer
Dim conn As Object
Dim rs As Object
Dim strLink As String
Dim strSql As String
Dim objExcel As Object
Dim i As Integer
Dim j As Integer
Let strSql = "select * from M_CALCHD"
Let strLink = "rovider=msdaora.1;Data Source=" & DATA_SOURCE & ";User Id=" & USER_ID & "assword=" & PASSWORD
Set conn = CreateObject("ADODB.Connection")
With conn
.CursorLocation = adUseClient
.ConnectionString = strLink
.Open
End With
Set rs = CreateObject("ADODB.Recordset")
rs.Open strSql, conn
MsgBox rs.RecordCount
If rs.RecordCount = -1 Then
MsgBox "found the data failed", 0 , "ERR"
End If
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.SheetsInNewWorkbook = 1
objExcel.Workbooks.Add
With objExcel.ActiveSheet
For j = 1 To rs.Fields.Count Step 1
.Cells(j, 1).Value = rs.Fields(j - 1).Name
Next j
i = 2
While Not rs.EOF
For j = 1 To rs.Fields.Count Step 1
MsgBox rs(j - 1).Value
.Cells(j, i).Value = rs(j - 1).Value
Next j
rs.MoveNext
i = i + 1
Wend
End With
' If Dir(strPath) <> "" Then
' Kill strPath
' End If
' objExcel.ActiveSheet.SaveAs strPath
'objExcel.Quit
CompareDatas = 0
End Function |
|