欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

ASP編程入門進階(廿一):DAO SQL之建立數(shù)據(jù)庫表

 更新時間:2007年01月03日 00:00:00   作者:  
你是否為自己設計的數(shù)據(jù)庫感到滿足了呢?你確信就不要對其再處理?比如新建立數(shù)據(jù)庫表,比如建立或者修改某個字段……當然這些都屬于設計數(shù)據(jù)庫之列。

那么,你正常的操作又是不是下載數(shù)據(jù)庫到本機,然后打開之進行修改,接著再上傳上去?十有八九都是如此-_-!

現(xiàn)在,你可以接觸下有關于此的信息了,畢竟代碼的功能是為手動的操作省了不少時間。不過代碼的生成也還不是手工?呵呵:)

1,建立數(shù)據(jù)庫文件cnbruce.mdb(不設計任何表)

建立數(shù)據(jù)庫的代碼:


<%
Option Explicit
dim databasename '定義數(shù)據(jù)庫名稱
databasename="cnbruce.mdb" '數(shù)據(jù)庫名稱
dim databasepath '定義數(shù)據(jù)庫存放路徑
databasepath="e:\cnbruce\database\" '數(shù)據(jù)庫絕對路徑
dim databasever '定義數(shù)據(jù)庫版本 2000 或者 97
databasever = "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) '創(chuàng)建數(shù)據(jù)庫
%>



那么,再看如何設計建立一個新的數(shù)據(jù)庫表吧

2,建立數(shù)據(jù)庫的連接文件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,建立新數(shù)據(jù)庫表的程序頁面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
%>
數(shù)據(jù)庫表文件建立完畢。



create table aboutme (id integer primary key,name text,Birthday datetime)
建立新的表aboutme,設計其字段有id(主關鍵字)、name(備注)、Birthday(時間日期)

相關文章

最新評論