<!--#include file="connection.asp"-->
<!--#include file="inc/const.asp"-->
<%Server.ScriptTimeOut=9999999
ConnectionDatabase()
dim act
act=request("act")
if act="" then
call main()
elseif act=1 then
call update()
end if
call  CloseObject()
sub main()
%>
<FORM METHOD=POST ACTION="?act=1">
<p align="center">&nbsp;
<br>
<input type=submit name=submit value="数据库升级"><BR>
</FORM>
<%end sub%>
<%
sub update()
dim sqlcmd
'--------------user----------------
call addcolumn("dv_user","Visual","Text",0,"")
call addcolumn("dv_user","period","Varchar",255,"")
response.write("升级成功！请不要刷新，直接回到上一页！")
end sub

Function addcolumn(nTable,nField,nType,nSize,nDefault)
	dim sqlcmd
	on error resume next
	
	if nSize=0 then
		if nDefault="" then
			sqlcmd="alter table [" & nTable & "] add column " & nField & " " & nType
		else
			sqlcmd="alter table [" & nTable & "] add column " & nField & " " & nType & " Default " & nDefault
		end if
	else
		if nDefault="" then
			sqlcmd="alter table [" & nTable & "] add column " & nField & " " & nType & "(" & nSize & ")"
		else
			sqlcmd="alter table [" & nTable & "] add column " & nField & " " & nType & "(" & nSize & ")" & " Default " & nDefault
		end if
	end if
	conn.execute sqlcmd
	if err.number=0 then
		response.write "成功添加" & nField & "字段于" & nTable & "表！<br>"
	else
		if err.number=-2147217887 then
			if nSize=0 then
				if nDefualt="" then
					sqlcmd="alter table [" & nTable & "] alter column " & nField & " " & nType
				else
					sqlcmd="alter table [" & nTable & "] alter column " & nField & " " & nType & " Default " & nDefault
				end if
			else
				if nDefualt="" then
					sqlcmd="alter table [" & nTable & "] alter column " & nField & "(" & nSize & ")" & nType
				else
					sqlcmd="alter table [" & nTable & "] alter column " & nField & "(" & nSize & ")" & nType & " Default " & nDefault
				end if
			end if
			conn.execute sqlcmd
			response.write nField & "字段在表" & nTable & "中已经存在，现" & nField & "字段的类型已经修改！<br>"
		else
			response.write nField & "字段添加到" & nTable & "失败！<br>"
		end if
	end if
End Function

Function SQLOperator(nTable,nSql)
	on error resume next
	
	conn.execute nSql
	if err.number=0 then
		response.write nTable & "操作执行成功！<br>"
	else
		response.write nTable & "操作执行不成功！<br>"
	end if
end Function
Sub  CloseObject()
	Set template = Nothing
	Set MyBoardOnline = Nothing
	Set Dvbbs = Nothing
	Set Conn = Nothing
End Sub
%>