|
有人可以帮忙解释下下面用AutoIt操作access数据库的例子每行的作用吗?我看了很久都不清楚是什么意思。。。
代码:
--------------------------------------------------------------------------------
$db>$tbl>$fld>$format="int"
$sData="123456"
$T="*"
_CreateDB($dbname)
_CreateTBL($dbname, $tblname)
_CreateFLD($dbname, $tblname, $fldname, $format)
;_InsertData($dbname, $tblname, $fldname, $sData)
;_DeleteData($dbname, $tblname, $fldname, $sData)
_SelectData($dbname, $tblname, $fldname, $T)
Func _CreateDB($dbname)
$newMdb = ObjCreate("ADOX.Catalog")
$newMdb.Create("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $dbname)
$newmdb.ActiveConnection.Close
EndFunc
Func _CreateTBL($dbname, $tblname)
$addtbl = ObjCreate("ADODB.Connection")
$addTbl.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $dbname)
$addTbl.Execute("CREATE TABLE " & $tblname)
$addtbl.Close
EndFunc
Func _CreateFLD($dbname, $tblname, $fldname, $format)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $dbname)
$addfld.Execute("ALTER TABLE " & $tblname & " ADD " & $fldname & " " & $format)
$addfld.Close
EndFunc
Func _InsertData($dbname, $tblname, $fldname, $sData)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $dbname)
$addfld.Execute("Insert Into " & $tblname & " (" & $fldname & ") " & "VALUES ("&$sData&")")
$addfld.Close
EndFunc
Func _DeleteData($dbname, $tblname, $fldname, $sData)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $dbname)
$addfld.Execute("Delete From " & $tblname & " Where " & $fldname & " = " &$sData)
$addfld.Close
EndFunc
Func _SelectData($dbname, $tblname, $fldname, $T)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $dbname)
$RS =ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open ("Select "&$T & " From " & $tblname )
msgbox(0,"",$RS.Fields(0).Name)
msgbox(0,"",$RS.Fields(0).Value)
$addfld.Close
EndFunc
while not $rs.eof and not $rs.bof
if @error =1 Then ExitLoop
$tempData=$tempData&($RS.Fields("value").Value)&"|"
$rs.movenext
WEnd |
|