|
本帖最后由 silvay22 于 2013-4-25 11:09 编辑
cross door大侠写了一个名为mssql.au3 的UDF ,这个UDF中有一个_InsertTbl()这个函数。在UDF中,原始定义如下:
#cs
Function name: _InsertTbl
Description: 往表中写入数据
Parameter(s): $oConnectionObj - _MsSQLConnect函数的返回值 $Tbl - 需写数据的表
$A_Row - 写入数据的列名,多列用英文逗号分隔 $A_data - 写入的数据
Example: _InsertTbl($oConnectionObj, "ceshitbl","pass,test","7000,0")
Return Value(s):成功返回 1. 失败返回0并设置 @error = 1
Requirement(s): Autoit 3 的COM组件支持
Author(s): crossdoor
#ce
Func _InsertTbl($oConnectionObj, $Tbl, $A_Row, $A_data);在表中写入指定数据
If IsObj($oConnectionObj) And Not @error Then
$RS = ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $oConnectionObj
If StringInStr($A_Row, ",") Then
$a = StringSplit($A_Row, ",", 1)
$b = StringSplit($A_data, ",", 1)
$data = ''
$Row = ''
For $i = 1 To $a[0]
If $i = 1 Then
$Row = $Row & $a[$i] & ","
$data = $data & $b[$i]
ElseIf $i = $a[0] Then
$Row = $Row & $a[$i]
$data = $data & "','" & $b[$i]
Else
$Row = $Row & $a[$i] & ","
$data = $data & "','" & $b[$i]
EndIf
Next
Else
$Row = $A_Row
$data = $A_data
EndIf
$oConnectionObj.Execute("insert into " & $Tbl & " (" & $Row & ") values ('" & $data & "')")
Return 1
Else
SetError(1)
Return 0
EndIf
EndFunc ;==>_InsertTbl
以上,是函数在UDF中的定义形式,而我写的函数调用如下
_InsertTbl($SqlConn, "Timage","number,image", $get[$i],$chars)
就报错了,主要是$get[$i],$chars为两个变量,如果像我一样要插入的是两个变量,这个函数该如何调用?请大家帮帮忙。先谢谢了 |
|