|
发表于 2014-11-21 12:30:30
|
显示全部楼层
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 & ";Jet Oledb:Database Password=" & $mdb_data_pwd)
$newMdb.ActiveConnection.Close;建数据库
$addtbl = ObjCreate("ADODB.Connection")
$addtbl.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path & ";Jet Oledb:Database Password=" & $mdb_data_pwd)
$addtbl.Execute("CREATE TABLE " & $tblname)
;$addtbl.Execute("CREATE TABLE ignorant")
$addtbl.Close;建表
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path & ";Jet Oledb:Database Password=" & $mdb_data_pwd)
$addfld.Execute("ALTER TABLE " & $tblname & " ADD id identity(1, 1) primary key ,address text ,ico text ,name text ,newid number");id identity(1, 1) primary key为自动编号和主键
$addfld.Close;建列表名 ADD id identity(1, 1) primary key
MsgBox(64, " 提示:", @CRLF & "建立数据库成功", 5)
Else
MsgBox(64, " 提示:", @CRLF & "你已经建立了一个数据库了....", 5)
EndIf
EndFunc ;==>data
Func du()
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path & ";Jet Oledb:Database Password=" & $mdb_data_pwd)
$RS = ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open("Select * From " & $tblname & " ORDER BY id ASC");
While Not $RS.eof And Not $RS.bof
If @error = 1 Then ExitLoop
ReDim $file[$n + 1][4]
$file[$n][0] = $RS.Fields(3).value
$file[$n][1] = $RS.Fields(1).value
$file[$n][2] = $RS.Fields(2).value
$file[$n][3] = $RS.Fields(4).value
$n = $n + 1
$RS.movenext
WEnd
$RS.close
$addfld.Close
Return $file
EndFunc ;==>du |
|