Are you satisfied with the database you designed? If you are sure, don't deal with it again? For example, creating a new database table, such as creating or modifying a certain field... Of course, these are all part of the design database.
So, in your normal operation, is it necessary to download the database to the local machine, then open it and modify it, and then upload it? This is most likely the case-_-!
Now, you can get in touch with information about this, after all, the function of the code saves a lot of time for manual operations. But the code generation is not manual? hehe:)
1. Create the database file cnbruce.mdb (no table design)
Code to create the database:
<% Option Explicit dim databasename 'Define database name databasename="cnbruce.mdb" 'Database name dim databasepath 'Define the database storage path databasepath="e:/cnbruce/database/" 'Absolute path of the database dim databasever 'Define database version 2000 or 97 databaseever = "2000" Function Createdfile(FilePath,FileName,Ver) Dim cnbruce,dbver select case ver case "97" dbver = "3.51" case "2000" dbver = "4.0" end select if dbver <> "" then Set cnbruce = Server.CreateObject("ADOX.Catalog") call cnbruce.Create("Provider=Microsoft.Jet.OLEDB." & dbver & ";Data Source=" & filepath & filename) end if End Function Call Createdfile(databasepath,databasename,databasever) 'Create a database %> |
Then, let’s look at how to design and create a new database table
2. Create a database connection file conn.asp
<% db_path = "cnbruce.mdb" Set conn= Server.CreateObject("ADODB.Connection") connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath(db_path) conn.Open connstr %> |
3. Create a new database table program page addtable.asp
<!--#include file="conn.asp" --> <% Set rs = Server.CreateObject ("ADODB.Recordset") sql = "create table aboutme (id integer primary key,name text,Birthday datetime)" rs.Open sql,conn,2,3 %> The database table file is created. |
create table aboutme (id integer primary key,name text,Birthday datetime)
Create a new table aboutme and design its fields include id (main keyword), name (note), and Birthday (time and date)