标题: 向大哥们求助脚本问题 [打印本页] 作者: kyo_zy 时间: 2008-3-14 14:11 标题: 向大哥们求助脚本问题 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作者: C060706 时间: 2008-3-14 15:59
兄台,rational用的脚本语言是VB吗?作者: kyo_zy 时间: 2008-3-14 16:13
不是可以用VB吗?我看见可以Ado访问数据库的,
我只是想把数据库的数据查询出来,然后保存到Excel文件
然后和预想值进行对比
那兄台可有什么解决办法?万分感谢