本帖最后由 xms77 于 2012-10-20 21:58 编辑
求数据库达人指教了,问题如下图,执行红框的代码就出错,执行绿框的代码就没有问题。运行环境3.3.7.15,win7 32bits
就算运行没有出错,但是创建的数据库用access打开,也会出现如下的报错$mdb_data_path = "HSA Machine Info.mdb"
$mdb_data_pwd = ""
$T = "*"
$tblname = "MachineInfo"
DBCreate($mdb_data_path, $tblname)
Func DBCreate($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,MachineType char ,MachineName char ,PCName char,IPAddress char,MachineStatus char,SoftwareRev char,ClientRev char,MacAddress char,UpdateDateTime char")
$addfld.Execute("ALTER TABLE " & $tblname & " ADD id identity(1, 1) primary key,MachineType char ,MachineName char ,PCName char,IPAddress char,MachineStatus char,SoftwareRev char,ClientRev char")
$addfld.Close;建列表名
MsgBox(64, "提示", "建立数据库成功", 5)
Else
MsgBox(64, "提示", "你已经建立了一个数据库了", 5)
EndIf
EndFunc ;==>data
问题解决了,谢谢大家的帮忙!把出错的那一行语句中的MacAddress char,UpdateDateTime char
改为MacAddress text(255),UpdateDateTime text(255)
就行了 |