'VB project reference as follows:' Microsoft ADO Ext 2.8 for DDL and Security'Microsoft ActiveX Data Objects 2.8 Library'COM Services Type Library'Microsoft DAO 3.6 Object LibrarySub CreateDatabase (mdbPath, mdbPassword).
Dim cat as new adox.catalogif mdbpassword = "" thecReate "provider = microsoft.jet.oledb.4.0; password =; data source" & mdbpath ";" elsecat.create "provike = microsoft.jet.Oledb.4.0 Password = "& mdbpassword"; data source = "& mdbpath &"; "'cat.create" provider = microsoft.jet.Oledb.4.0; data source = "& mdbpath"; "END IFMSGBOX" Database "&" MDBPATH & "Establishment", Vbokonly'Set Wspdefault = DBENGINE.WORKSPACES (0) 'SET DBS = Wspdefault.createdDatabase ("NewDb.mdb", _'DBlangGeneral & "PWD = newpassword", dbencrypt)
End Sub
Sub CreateTable (mdbPath, mdbTableName, mdbSqlColumns, mdbPrimaryKey) 'column establishing sql statement' mdbPath = "c: /test.mdb" 'mdbTableName = "User"' mdbSqlColumns = "ID, adInteger; UserName, adVarWChar, 20; Password, adVarWChar, 20 " 'mdbPrimaryKey =" ID "Dim tbl As New TableDim cat As New ADOX.CatalogDim con As ADODB.Connectioncat.ActiveConnection =" Provider = Microsoft.Jet.OLEDB.4.0; Password =; Data Source = "& mdbPath & ";"
DIM arraycolumn as stringtbl.name = mdbtablename
'Add Data Table field (field format: field name field category, field length; no segment of the last field) ArrayTotalColumn = Split (mdbsqlcolumns, ";", -1, 1) for i = 0 to Ubound (arraytotalcolumn) arraysinglecolumn = Split (ArrayTotalColumn (i), ",", -1, 1) If UBound (ArraySingleColumn) = 1 Then 'tbl.Columns.Append ArraySingleColumn (0), ArraySingleColumn (1) tbl.Columns.Append ArraySingleColumn (0), adInteger Else 'tbl.Columns.Append ArraySingleColumn (0), ArraySingleColumn (1), ArraySingleColumn (2) tbl.Columns.Append ArraySingleColumn (0), adVarWChar, CInt (ArraySingleColumn (2)) End If Next' setting data table's primary key 'tbl .Columns (mdbprimarykey) .properties ("AutoInCrement" = TrueCat.Tables.Append TBL 'Setting column must be "No"' TBL.COLUMNS ("Weight"). Attributes = adcolnull 'Settings Allow empty characters The string is "is" "firstname"). Properties ("Jet OLEDB: Allow Zero Length") = True Set TBL = Nothing Set Cat = NothingMsGBox "Dataset" & MDBPath & "-" & MDBTABLENAME & " Establish success, "Vbokonlynd Sub
'This is ready to write into a class. 'In fact, the ASP operation of the ASP operation, the ACCESS database, the ACCESS database, the basics, the basic similar "database - new, delete, compression, fix, set password, database file existence judgment, read' 'data table - new, delete , Data table name read, judgment, delete, update 'data field - new, modified, primary key, allow empty, length, foreign key, index, field name list, judgment, attribute setting