大家好!
最近在学习用au3写数据时发现的一个问题,在对建立的新表添加字段时超过8个就会出一些以下错误:
$addfld.Execute("ALTER TABLE " & $tblname & " ADD id identity(1, 1) primary key,a char,b char,c char,d char,e char,f char,g char,h char")^ ERROR
但是如果把代码修改成下面少一个字段:
$addfld.Execute("ALTER TABLE " & $tblname & " ADD id identity(1, 1) primary key,a char,b char,c char,d char,e char,f char,g char")
就不会出错!
这个字段数目有8个限制的问题,在做更新表操作时也存在,不知道是au3的BUG还是我的代码那里有问题!
希望大家帮忙看看,谢谢!
以下是代码:
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 291, 132, 282, 248)
$Button1 = GUICtrlCreateButton("Test建立数据库", 80, 56, 121, 41, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Func _data($mdb_data_path, $tblname)
if not FileExists($mdb_data_path) Then
$newMdb = ObjCreate("ADOX.Catalog")
$newMdb.Create("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path)
$newmdb.ActiveConnection.Close;建数据库
$addtbl = ObjCreate("ADODB.Connection")
$addTbl.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path)
$addTbl.Execute("CREATE TABLE " & $tblname)
$addtbl.Close;建表
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path)
$addfld.Execute("ALTER TABLE " _
& $tblname & " ADD id identity(1, 1) primary key,a char,b char,c char,d char,e char,f char,g char,h char");id identity(1, 1) primary key为自动编号和主键
$addfld.Close;建列表名
MsgBox(64,"提示","建立数据库成功",5)
Else
MsgBox(64,"提示","你已经建立了一个数据库了",5)
EndIf
EndFunc
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
Local $mdb_data_path = "test.mdb"
Local $tblname="Computer"
_data($mdb_data_path, $tblname)
EndSwitch
WEnd
[ 本帖最后由 sheep_autoit 于 2009-1-4 21:08 编辑 ] |