快捷搜索:

用ASP自动生成SQL数据库的安装源程序

chinaasp论坛完备法度榜样下载:

http://www.yescnet.com/manage.asp?url=down/list.asp**id=89

http://user.7host.com/yescnet/manage.asp?url=down/list.asp**id=90

由于我装的是MSDE,没有发明查询阐发器,也没法子运行sql文件,我到处支找SQL的光盘也找不到,苦

恼了好一陈子。只能在导出导入里新建一个数据库(呵呵,发明在ms.net里居然可以编辑查看sql数据

库,虽然也不能运行sql,不过给了我不少方便),就此写了一个ASP文件。全自动的天生chinaasp的sql

数据库。

去chinaasp不感觉什么,现在真正解开他的内容一看,真的令人叹服,委实是杰作中的杰作。难怪这么

多人效仿而乐此不疲。

假如你有查询阐发器,这个用一下反正也很方便,假如你没有查询阐发器,那是更好了,此中连接SQL的

可能是被人改了,不能用,我都改好了。

今后假如写其他的SOL数据库,只要打开conn.asp与setup.asp。依样画葫芦便是了,总之自已手写出来的

器械,用得特惬意。

声明:好象chinaasp不供给免费应用的授权,我也不太清楚,这个纯挚是小我钻研,弗成以真的拿去用了

或改了。

CONN.ASP文件:

<%

dim conn

dim connstr

connstr="driver={SQL Server};server=localhost;UID=sa;PWD=;database=bbsbbs"

set conn=server.createobject("ADODB.CONNECTION")

if err.number<>0 then

err.clear

set conn=nothing

Response.Write "创建ADO工具掉败"

Response.End

else

conn.open connstr

if err then

err.clear

set conn=nothing

Response.Write "SQL数据库连接掉败,请反省数据库是否存在,以及odbc是否存在"

Response.End

end if

end if

sub endConnection()

conn.close

end sub

%>

setup.asp文件:

<!--#include file="conn.asp"-->

<html>

<STYLE TYPE="text/css">

<!--

body{

BACKGROUND: white;

FONT-FAMILY: 宋体;

FONT-SIZE: 75%

}

-->

</STYLE>

<title>chinaasp安装</title><body>

<%

If Request.QueryString("setup") = "yes" Then

on error resume next

Set adoRS = Server.CreateObject("ADODB.Recordset")

strSQL = "CREATE TABLE Announce ( "

strSQL =strSQL +"AnnounceID int IDENTITY (1, 1) NOT NULL ,"

strSQL =strSQL +"ParentID int NULL , "

strSQL =strSQL +"Child int NULL , "

strSQL =strSQL +"BoardID int NULL , "

strSQL =strSQL +"UserName nvarchar (50) NULL , "

strSQL =strSQL +"UserEmail nvarchar (255) NULL , "

strSQL =strSQL +"URL nvarchar (255) NULL , "

strSQL =strSQL +"URLTitle nvarchar (255) NULL , "

strSQL =strSQL +"URLPic nvarchar (255) NULL , "

strSQL =strSQL +"Topic nvarchar (255) NULL , "

strSQL =strSQL +"Body ntext NULL , "

strSQL =strSQL +"DateAndTime datetime NULL , "

strSQL =strSQL +"hits int NULL , "

strSQL =strSQL +"length int NULL , "

strSQL =strSQL +"RootID int NULL , "

strSQL =strSQL +"layer int NULL , "

strSQL =strSQL +"orders int NULL , "

strSQL =strSQL +"emote int NULL , "

strSQL =strSQL +"ip nvarchar (20) NULL , "

strSQL =strSQL +"signature nvarchar (255) NULL , "

strSQL =strSQL +"replyMail bit NOT NULL "

strSQL =strSQL +") "

Set adoRS = Conn.Execute(strSQL)

strSQL ="CREATE TABLE board ("

strSQL =strSQL +"BoardID int IDENTITY (1, 1) NOT NULL , "

strSQL =strSQL +"BoardName nvarchar (100) NULL ,"

strSQL =strSQL +"BoardMaster int NULL , "

strSQL =strSQL +"BoardMaster2 int NULL , "

strSQL =strSQL +"BoardMaster3 int NULL , "

strSQL =strSQL +"cateID int NULL , "

strSQL =strSQL +"description nvarchar (500) NULL "

strSQL =strSQL +") "

Set adoRS = Conn.Execute(strSQL)

strSQL ="CREATE TABLE boardCate ("

strSQL =strSQL +"id int IDENTITY (1, 1) NOT NULL , "

strSQL =strSQL +"CateName nvarchar (50) NOT NULL , "

strSQL =strSQL +"Description nvarchar (244) NULL , "

strSQL =strSQL +"Orders int NULL "

strSQL =strSQL +") "

Set adoRS = Conn.Execute(strSQL)

strSQL ="CREATE TABLE essence ("

strSQL =strSQL +"id int IDENTITY (1, 1) NOT NULL , "

strSQL =strSQL +"announceid int NULL , "

strSQL =strSQL +"boardid int NULL , "

strSQL =strSQL +"username nvarchar (50) NULL , "

strSQL =strSQL +"useremail nvarchar (255) NULL , "

strSQL =strSQL +"url nvarchar (255) NULL , "

strSQL =strSQL +"urlTitle nvarchar (255) NULL , "

strSQL =strSQL +"urlPic nvarchar (255) NULL , "

strSQL =strSQL +"Topic nvarchar (255) NULL , "

strSQL =strSQL +"Body ntext NULL , "

strSQL =strSQL +"dateAndTime nvarchar (50) NULL , "

strSQL =strSQL +"hits int NULL , "

strSQL =strSQL +"length int NULL , "

strSQL =strSQL +"emote int NULL , "

strSQL =strSQL +"keywords nvarchar (255) NULL "

strSQL =strSQL +") "

Set adoRS = Conn.Execute(strSQL)

strSQL ="CREATE TABLE site ( "

strSQL =strSQL +"SiteMasterPwd nvarchar (50) NULL "

strSQL =strSQL +") "

Set adoRS = Conn.Execute(strSQL)

strSQL ="CREATE TABLE [user] ( "

strSQL =strSQL +"UserID int IDENTITY (1, 1) NOT NULL , "

strSQL =strSQL +"UserName nvarchar (50) NULL , "

strSQL =strSQL +"UserEmail nvarchar (255) NULL , "

strSQL =strSQL +"UserPassword nvarchar (11) NULL , "

strSQL =strSQL +"icq nvarchar (20) NULL , "

strSQL =strSQL +"homepage nvarchar (255) NULL , "

strSQL =strSQL +"sex nvarchar (10) NULL , "

strSQL =strSQL +"passanswer nvarchar (100) NULL , "

strSQL =strSQL +"incometime smalldatetime NULL , "

strSQL =strSQL +"birthday smalldatetime NULL , "

strSQL =strSQL +"points int NULL , "

strSQL =strSQL +"visits int NULL , "

strSQL =strSQL +"country nvarchar (20) NULL , "

strSQL =strSQL +"city nvarchar (20) NULL , "

strSQL =strSQL +"passquest nvarchar (100) NULL , "

strSQL =strSQL +"signature nvarchar (255) NULL , "

strSQL =strSQL +"disabled int NULL "

strSQL =strSQL +") "

Set adoRS = Conn.Execute(strSQL)

strSQL ="ALTER TABLE [boardCate] WITH NOCHECK ADD CONSTRAINT [PK_boardCate] PRIMARY KEY CLUSTERED ([id])"

Set adoRS = Conn.Execute(strSQL)

strSQL ="ALTER TABLE [Announce] WITH NOCHECK ADD CONSTRAINT [DF__announce__replyM__3F466844] DEFAULT (0) FOR [replyMail],"

strSQL =strSQL +"CONSTRAINT [PK_Announce] PRIMARY KEY NONCLUSTERED ([AnnounceID])"

Set adoRS = Conn.Execute(strSQL)

strSQL ="ALTER TABLE [board] WITH NOCHECK ADD CONSTRAINT [PK_board] PRIMARY KEY NONCLUSTERED ([BoardID])"

Set adoRS = Conn.Execute(strSQL)

strSQL ="ALTER TABLE [essence] WITH NOCHECK ADD CONSTRAINT [PK_essence] PRIMARY KEY NONCLUSTERED ([id])"

Set adoRS = Conn.Execute(strSQL)

strSQL ="ALTER TABLE [user] WITH NOCHECK ADD CONSTRAINT [DF_user_disabled] DEFAULT (0) FOR [disabled],"

strSQL =strSQL +"CONSTRAINT [PK_user] PRIMARY KEY NONCLUSTERED ([UserID])"

Set adoRS = Conn.Execute(strSQL)

strSQL ="CREATE INDEX [Boardid] ON [Announce]([BoardID])"

Set adoRS = Conn.Execute(strSQL)

strSQL ="CREATE INDEX [announce0] ON [Announce]([BoardID], [AnnounceID], [ParentID])"

Set adoRS = Conn.Execute(strSQL)

strSQL ="CREATE INDEX [IX_Announce] ON [Announce]([orders])"

Set adoRS = Conn.Execute(strSQL)

strSQL ="CREATE INDEX [announce00] ON [Announce]([RootID], [BoardID], [orders])"

Set adoRS = Conn.Execute(strSQL)

strSQL ="CREATE INDEX [IX_boardCate] ON [boardCate]([Orders])"

Set adoRS = Conn.Execute(strSQL)

strSQL ="CREATE INDEX [Boardid] ON [essence]([boardid])"

Set adoRS = Conn.Execute(strSQL)

strSQL ="CREATE INDEX [points] ON [user]([points])"

Set adoRS = Conn.Execute(strSQL)

strSQL ="CREATE INDEX [username] ON [dbo].[user]([UserName])"

Set adoRS = Conn.Execute(strSQL)

strSQL ="CREATE INDEX [IX_user] ON [dbo].[user]([UserName])"

Set adoRS = Conn.Execute(strSQL)

strSQL ="insert site(sitemasterpwd) values('12345')"

Set adoRS = Conn.Execute(strSQL)

strSQL ="alter table announce add lock bit NOT NULL DEFAULT (0)"

Set adoRS = Conn.Execute(strSQL)

%>

<p> </p>

<p>操作成功,请勿在相同的数据库重复安装, <a href="DEFAULT.ASP" target="_blank" >请登录论坛</a><br>

<br>

<br>

<a href="admin" target="_blank">治理密码已为您设置为12345,请登录治理页面</a> </p>

<%

Else

Response.Write("<a href=setup.asp?setup=yes>单击此处开始安装</a><br><br><br><a href=""http://www.yescnet.com"">一鹤的chinaasp论坛数据库安装法度榜样</a> ")

End If

%>

<hr>

<p align="center"><br>

<a href="http://www.yescnet.com" target="_blank" >一鹤的chinaasp论坛数据库安装法度榜样</a> ||

<a href="http://www.yescnet.com">CNET中文网</a> || <a href="http://www.yescnet.com">WWW.YESCNET.COM</a></p>

</body></html>

您可能还会对下面的文章感兴趣: