发表于:2006-11-21 09:07:00
楼主
小弟我在Wincc全局脚本程序中定义了一个函数Function1(strSQL),通过传递过来的SQL语句执行查询操作并返回数据集Recordset,现在要在别的按钮动作里调用这个函数,并将函数运行结果Recordset返回,以便对返回结果进行处理.
我的代码如下
Function ReadrecordDB(strSQL)
Dim objConnection
Dim objCommand
Dim objRecordset
Dim strConnectionString
strConnectionString = ".........................(此处省略了)"
Set objConnection = CreateObject("ADODB.Connection")
objConnection.ConnectionString = strConnectionString
objConnection.Open
Set objRecordset = CreateObject("ADODB.Recordset")
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.CommandText = strSQL
Set objRecordset = objCommand.Execute
Set objCommand = Nothing
objConnection.Close
Set objRecordset = Nothing
Set objConnection = Nothing
ReadrecordDB = objRecordset.clone()
End Function
其他程序调用
......
Set Count = CreateObject("ADODB.Recordset")
Count = ReadrecordDB(strSQL)
Value1 = Count.Fields(0).value
Value2 = Count.Fields(1).value
......
......
但是运行调试的时候提示在Function中的
ReadrecordDB = objRecordset.clone()
处有语法错误,错误信息是:
Wrong number of arguments or invalid property assignment
哪位大哥大姐给点指点吧,小弟在此谢过了!