因为我装的是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>