在线数据库管理工具(db007) v1.5

2018-09-06 12:32

阅读:1533

  在线数据库管理工具 db007 下载://

复制代码 代码如下:
<!--
********************************
*用途:
^以视图界面方式在线处理access、sql数据库
*作者:官世杰
*创建日期:2006-5-28
*2006-06-04增加数据修改功能
*2006-06-10增加了在空表中插入数据功能
*2006-09-8增加修改字段名和表名功能,修正部分错误
*执行sql,如果是select就返回结果,否则返回执行结果
*本程序可以免费使用,转载请保留此信息
********************************
-->
<html>
<head>
<metahttp-equiv=Content-Typecontent=text/html;charset=gb2312>
<title>在线数据库管理工具db0071.5</title>
<styletype=text/css>
<!--
body,td,th{font-family:宋体;font-size:12px;}
form{margin:0px;padding:0px;}
body{margin:5px;SCROLLBAR-ARROW-COLOR:#666666;SCROLLBAR-FACE-COLOR:#DDDDDD;SCROLLBAR-DARKSHADOW-COLOR:#999999;SCROLLBAR-HIGHLIGHT-COLOR:#FFFFFF;SCROLLBAR-3DLIGHT-COLOR:#CCCCCC;SCROLLBAR-SHADOW-COLOR:#FFFFFF;SCROLLBAR-TRACK-COLOR:#EEEEEE;}
input{border-width:1px;border-style:solid;border-color:#CCCCCC#999999#999999#CCCCCC;height:16px;}
td{background:#FFF;}
textarea{border-width:1px;border-style:solid;border-color:#CCCCCC#999999#999999#CCCCCC;}
a:link{text-decoration:none;}
a:visited{text-decoration:none;}
a:hover{text-decoration:underline;}
a:active{text-decoration:none;}
.fixSpan{width:150px;white-space:nowrap;word-break:keep-all;overflow:hidden;text-overflow:ellipsis;}
-->
</style>
</head>

<body>
<%
ifrequest(key)=dbthen
session(dbtype)=request(dbtype)
session(dbstr)=request(dbstr)
response.redirect?
endif

ifrequest(key)=createdatabasethen
callcreatedatabase()
endif

ifsession(dbtype)=orsession(dbstr)=then
%>
<formaction=?key=dbmethod=postname=dbt>
<br>
连接类型:
<inputname=dbtypetype=radiovalue=accessonClick=dbstr.value=Provider=Microsoft.Jet.OLEDB.4.0;PersistSecurityInfo=False;Password=;DataSource=<%=server.mappath(/)&\%>checked>
ACCESS
<inputdisabled=disabledtype=radioname=dbtypevalue=sqlonClick=dbstr.value=driver={SQLServer};database=;Server=;uid=;pwd=>
SQL<br><br>
连接字符:<inputname=dbstrtype=textid=dbstrsize=120value=Provider=Microsoft.Jet.OLEDB.4.0;PersistSecurityInfo=False;Password=;DataSource=<%=server.mappath(/)&\%>>
<inputtype=submitname=Submitvalue=连接/><br><br>
注:access请使用绝对路径,本文件路径:<%=server.MapPath(db007.asp)%>
</form>
<formname=createdatabasemethod=postaction=?key=createdatabase>
<fontcolor=red>创建数据库:</font>路径
<inputname=datanametype=textvalue=<%=server.MapPath(/)&\database.mdb%>size=100>
<inputtype=submitname=Submitvalue=创建>
</form>
<%
response.End()
endif

==================================================================建库
subcreatedatabase()
dimDBName,dbstr,myCat
onerrorresumenext
DBName=request(dataname)
dbstr=PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATASOURCE=&DBName
SetmyCat=Server.CreateObject(ADOX.Catalog)
myCat.Createdbstr

iferr<>0then
response.writeerr.description
session(dbtype)=
session(dbstr)=
response.write<inputtype=buttonname=okvalue=返回onClick=javascript:history.go(-1)>
response.end
endif

session(dbtype)=access
session(dbstr)=dbstr
response.redirect?
endsub

==================================================================调用链接函数
conn()

functionconn()
dimconn1,connstr
onerrorresumenext
selectcasesession(dbtype)
caseaccess
==================================================================连接ACCESS数据库
connstr=session(dbstr)
conn1.Openconnstr
casesql
==================================================================连接SQL数据库
setconn1=Server.CreateObject(ADODB.Connection)
conn1.opensession(dbstr)
endselect

iferr<>0then
response.writeerr.description
session(dbtype)=
session(dbstr)=
response.write<inputtype=buttonname=okvalue=返回onClick=javascript:history.go(-1)>
response.end
endif

setconn=conn1
endfunction


Subecho(str)
Response.Write(str)
EndSub

FunctionIIf(var,val1,val2)
Ifvar=TrueThen
IIf=val1
Else
IIf=val2
EndIf
EndFunction

正则表达式函数,用于删除注释
-------------------------------------
FunctionRegExpReplace(strng,patrn,replStr)
DimregEx,match,matches建立变量。
SetregEx=NewRegExp建立正则表达式。
regEx.Pattern=patrn设置模式。
regEx.IgnoreCase=True设置是否区分大小写。
regEx.Global=True设置全局可用性。

RegExpReplace=regEx.Replace(strng,replStr)作替换。
EndFunction

==================================================================ADOVBS常量声明

----DataTypeEnumValues----
ConstadEmpty=0
ConstadTinyInt=16
ConstadSmallInt=2
ConstadInteger=3
ConstadBigInt=20
ConstadUnsignedTinyInt=17
ConstadUnsignedSmallInt=18
ConstadUnsignedInt=19
ConstadUnsignedBigInt=21
ConstadSingle=4
ConstadDouble=5
ConstadCurrency=6
ConstadDecimal=14
ConstadNumeric=131
ConstadBoolean=11
ConstadError=10
ConstadUserDefined=132
ConstadVariant=12
ConstadIDispatch=9
ConstadIUnknown=13
ConstadGUID=72
ConstadDate=7
ConstadDBDate=133
ConstadDBTime=134
ConstadDBTimeStamp=135
ConstadBSTR=8
ConstadChar=129
ConstadVarChar=200
ConstadLongVarChar=201
ConstadWChar=130
ConstadVarWChar=202
ConstadLongVarWChar=203
ConstadBinary=128
ConstadVarBinary=204
ConstadLongVarBinary=205

----FieldAttributeEnumValues----
ConstadFldMayDefer=&H00000002
ConstadFldUpdatable=&H00000004
ConstadFldUnknownUpdatable=&H00000008
ConstadFldFixed=&H00000010
ConstadFldIsNullable=&H00000020
ConstadFldMayBeNull=&H00000040
ConstadFldLong=&H00000080
ConstadFldRowID=&H00000100
ConstadFldRowVersion=&H00000200
ConstadFldCacheDeferred=&H00001000

----SchemaEnumValues----
----SchemaEnumValues----
ConstadSchemaProviderSpecific=-1
ConstadSchemaAsserts=0
ConstadSchemaCatalogs=1
ConstadSchemaCharacterSets=2
ConstadSchemaCollations=3
ConstadSchemaColumns=4
ConstadSchemaCheckConstraints=5
ConstadSchemaConstraintColumnUsage=6
ConstadSchemaConstraintTableUsage=7
ConstadSchemaKeyColumnUsage=8
ConstadSchemaReferentialConstraints=9
ConstadSchemaTableConstraints=10
ConstadSchemaColumnsDomainUsage=11
ConstadSchemaIndexes=12
ConstadSchemaColumnPrivileges=13
ConstadSchemaTablePrivileges=14
ConstadSchemaUsagePrivileges=15
ConstadSchemaProcedures=16
ConstadSchemaSchemata=17
ConstadSchemaSQLLanguages=18
ConstadSchemaStatistics=19
ConstadSchemaTables=20
ConstadSchemaTranslations=21
ConstadSchemaProviderTypes=22
ConstadSchemaViews=23
ConstadSchemaViewColumnUsage=24
ConstadSchemaViewTableUsage=25
ConstadSchemaProcedureParameters=26
ConstadSchemaForeignKeys=27
ConstadSchemaPrimaryKeys=28
ConstadSchemaProcedureColumns=29
ConstadSchemaDBInfoKeywords=30
ConstadSchemaDBInfoLiterals=31
ConstadSchemaCubes=32
ConstadSchemaDimensions=33
ConstadSchemaHierarchies=34
ConstadSchemaLevels=35
ConstadSchemaMeasures=36
ConstadSchemaProperties=37
ConstadSchemaMembers=38
ConstadSchemaTrustees=39
ConstadSchemaFunctions=40
ConstadSchemaActions=41
ConstadSchemaCommands=42
ConstadSchemaSets=43

==================================================================返回字段类型函数
Functiontyp(field_type)
field_type=字段类型值
SelectCasefield_type
caseadEmpty:typ=Empty
caseadTinyInt:typ=TinyInt
caseadSmallInt:typ=SmallInt
caseadInteger:typ=Integer
caseadBigInt:typ=BigInt
caseadUnsignedTinyInt:typ=TinyIntUnsignedTinyInt
caseadUnsignedSmallInt:typ=UnsignedSmallInt
caseadUnsignedInt:typ=UnsignedInt
caseadUnsignedBigInt:typ=UnsignedBigInt
caseadSingle:typ=SingleSingle
caseadDouble:typ=DoubleDouble
caseadCurrency:typ=MoneyCurrency
caseadDecimal:typ=Decimal
caseadNumeric:typ=NumericNumeric
caseadBoolean:typ=BitBoolean
caseadError:typ=Error
caseadUserDefined:typ=UserDefined
caseadVariant:typ=Variant
caseadIDispatch:typ=IDispatch
caseadIUnknown:typ=IUnknown
caseadGUID:typ=GUIDGUID
caseadDATE:typ=DateTimeDate
caseadDBDate:typ=DBDate
caseadDBTime:typ=DBTime
caseadDBTimeStamp:typ=DateTimeDBTimeStamp
caseadBSTR:typ=BSTR
caseadChar:typ=Char
caseadVarChar:typ=VarChar
caseadLongVarChar:typ=LongVarChar
caseadWChar:typ=TextWChar类型SQL中为Text
caseadVarWChar:typ=VarCharVarWChar
caseadLongVarWChar:typ=TextLongVarWChar
caseadBinary:typ=Binary
caseadVarBinary:typ=VarBinary
caseadLongVarBinary:typ=LongBinaryLongVarBinary
caseadChapter:typ=Chapter
caseadPropVariant:typ=PropVariant
caseelse:typ=Unknown
endselect
EndFunction

==================================================================返回字段类型列表
Functionfieldtypelist(n)
dimstrlist,str1,str2
strlist=<selectname=field_type>
ifsession(dbtype)=accessthen
strlist=strlist&<optionvalue=VarChar>文本</option>
strlist=strlist&<optionvalue=Text>备注</option>
strlist=strlist&<optionvalue=Bit>(是/否)</option>
strlist=strlist&<optionvalue=TinyInt>数字(字节)</option>
strlist=strlist&<optionvalue=SmallInt>数字(整型)</option>
strlist=strlist&<optionvalue=Integer>数字(长整型)</option>
strlist=strlist&<optionvalue=Single>数字(单精度)</option>
strlist=strlist&<optionvalue=Double>数字(双精度)</option>
strlist=strlist&<optionvalue=Numeric>数字(小数)</option>
strlist=strlist&<optionvalue=GUID>数字(同步ID)</option>
strlist=strlist&<optionvalue=DateTime>时间/日期</option>
strlist=strlist&<optionvalue=Money>货币</option>
strlist=strlist&<optionvalue=Binary>二进制</option>
strlist=strlist&<optionvalue=LongBinary>长二进制</option>
strlist=strlist&<optionvalue=LongBinary>OLE对象</option>

else
strlist=strlist&<optionvalue=>选择类型</option>
strlist=strlist&<optionvalue=BigInt>bigint</option>
strlist=strlist&<optionvalue=Binary>binary(二进制数据类型)</option>
strlist=strlist&<optionvalue=Bit>bit(整型)</option>
strlist=strlist&<optionvalue=Char>char(字符型)</option>
strlist=strlist&<optionvalue=DateTime>datetime(日期时间型)</option>
strlist=strlist&<optionvalue=Decimal>decimal(精确数值型)</option>
strlist=strlist&<optionvalue=Float>float(近似数值型)</option>
strlist=strlist&<optionvalue=Image>image(二进制数据类型)</option>
strlist=strlist&<optionvalue=Int>int(整型)</option>
strlist=strlist&<optionvalue=Money>money(货币型)</option>
strlist=strlist&<optionvalue=nchar>nchar(统一编码字符型)</option>
strlist=strlist&<optionvalue=ntext>ntext(统一编码字符型)</option>
strlist=strlist&<optionvalue=numeric>numeric(精确数值型)</option>
strlist=strlist&<optionvalue=nvarchar>nvarchar(统一编码字符型)</option>
strlist=strlist&<optionvalue=real>real(近似数值型)</option>
strlist=strlist&<optionvalue=smalldatetime>Smalldatetime(日期时间型)</option>
strlist=strlist&<optionvalue=smallint>smallint(整型)</option>
strlist=strlist&<optionvalue=smallmoney>smallmoney(货币型)</option>
strlist=strlist&<optionvalue=sql_variant>sql_variant()</option>
strlist=strlist&<optionvalue=text>text(字符型)</option>
strlist=strlist&<optionvalue=timestamp>timestamp(特殊数据型)</option>
strlist=strlist&<optionvalue=tinyint>tinyint(整型)</option>
strlist=strlist&<optionvalue=uniqueidentifier>Uniqueidentifier(特殊数据型)</option>
strlist=strlist&<optionvalue=varbinary>varbinary(二进制数据类型)</option>
strlist=strlist&<optionvalue=varchar>varchar(字符型)</option>
endif
str1=&n&
str2=&n&&selected
strlist=replace(strlist,str1,str2)
strlist=strlist&</select>
echostrlist
EndFunction

==================================================================主界面
submain(str)
onerrorresumenext
%>
<scriptlanguage=javascript>
ie=(document.all)?true:false
if(ie){
functionctlent(eventobject){if(event.ctrlKey&&
window.event.keyCode==13){this.document.exesql.submit();}}
}
</script>
<scriptlanguage=javascript>
functiontable_delete()
{
if(confirm(确认删除该记录吗?该操作将不可撤销!!!))
returntrue;
else
returnfalse;
}
</script>

<formaction=?key=sqlmethod=postname=exesql>
<fontcolor=red>执行sql语句:</font><fontcolor=#999999>(每句语句以“;”结束,支持(--)SQL注释,Ctrl+Enter快速提交)</font><inputtype=buttonvalue=刷新本页onClick=javascript:location.reload()>
<spanonClick=document.exesql.sql.rows+=5;style=cursor:pointer;>+</span>
<spanonClick=if(document.exesql.sql.rows>9)document.exesql.sql.rows-=5style=cursor:pointer;>-</span>
<divstyle=float:left;width:600px;>
<textareaid=sqlname=sqlstyle=width:600px;rows=9ondblClick=this.select();onKeyDown=ctlent()><%=request(sql)%></textarea><br/>
<inputtype=checkboxname=SchemaTablevalue=1style=border:0px;>adSchemaTables
<inputtype=checkboxname=SchemaColumnvalue=2style=border:0px;>adSchemaColumns
<inputtype=checkboxname=SchemaProvidervalue=3style=border:0px;>adSchemaProviderTypes
分页大小:
<selectname=pageSize>
<%
ifrequest(pageSize)<>andisNumeric(request(pageSize))then
echo<optionvalue=&request(pageSize)&selected>&request(pageSize)&</option>
else
echo<optionvalue=50>50</option>
endif
%>
<optionvalue=10>10</option>
<optionvalue=20>20</option>
<optionvalue=30>30</option>
<optionvalue=40>40</option>
<optionvalue=50>50</option>
<optionvalue=60>60</option>
<optionvalue=70>70</option>
<optionvalue=80>80</option>
<optionvalue=90>90</option>
<optionvalue=100>100</option>
</select>

</div>
<divstyle=float:left;width:50px;padding:60px0px0px5px;>
<inputtype=submitname=Submit_confirmvalue=提交><br/><br/>
<inputtype=buttonname=Submit3value=清空onClick=sql.value=><br/><br/>
<inputtype=buttonname=okvalue=返回onClick=javascript:history.go(-1)>
</div>
</form>
<divstyle=clear:both></div>
<%ifstr=then%>
<formaction=?key=addtablemethod=post>
<divstyle=clear:both;text-align:left;><br/>
<fontcolor=red>创建新表:</font><br>
表名:<inputtype=textname=table_namesize=20><br>
字段数:<inputtype=textname=field_numsize=20>
<inputtype=submitname=Submit_createvalue=提交>
<inputtype=resetname=Submit32value=重置>
</div>
</form>
<br><br>
<ahref=?key=tosql&strt=2>导出所有表结构到SQL</a>
<%
endif
endsub

==================================================================创建表界面
subadd_table(table_name,field_num)
table_name=表名称
field_num=字段数
onerrorresumenext
ifnotIsNumeric(field_num)then
echo字段数必须是整数。
echo<inputtype=buttonname=okvalue=返回onClick=javascript:history.go(-1)>
exitsub
endif
%>
<pclass=hei><span>创建表:</span><%=table_name%></p>
<formaction=?key=createtablemethod=post>
<tablewidth=600border=0cellpadding=2cellspacing=1bgcolor=#CCCCCC>
<tr>
<tdwidth=75height=20align=center>字段名</td>
<tdwidth=99height=20align=center>类型</td>
<tdwidth=73height=20align=center>大小</td>
<tdwidth=96height=20align=center>空值</td>
<tdwidth=83height=20align=center>自动编号</td>
<tdwidth=143height=20align=center>主键</td>
</tr>
<%fori=0tofield_num-1%>
<tr>
<tdwidth=75height=20align=center>
<inputtype=textname=field_namesize=10>
</td>
<tdwidth=99height=20align=center>
<%fieldtypelist(0)%>
</td>
<tdwidth=73height=20align=center>
<inputtype=textname=field_sizesize=10>
</td>
<tdwidth=96height=20align=center>
<selectname=null>
<optionvalue=NOT_NULL>NOT_NULL</option>
<optionvalue=NULL>NULL</option>
</select>
</td>
<tdwidth=83height=20align=center>
<selectsize=1name=autoincrement>
<option></option>
<option>自动编号</option>
</select>
</td>
<tdwidth=143height=20align=left>
<selectname=primarykey>
<option></option>
<optionvalue=primarykey>primarykey</option>
</select>
</td>
</tr>
<%next%>
<tr>
<tdheight=35align=centercolspan=5>
<inputtype=hiddenname=ivalue=<%=field_num%>>
<inputtype=hiddenname=table_namevalue=<%=table_name%>>
<inputtype=submitname=Submitvalue=提交>

<inputtype=resetname=Submit2value=重置>

<inputtype=buttonname=okvalue=放弃onClick=javascript:history.go(-1)>
</td>
<tdheight=20></td>
</tr>
</table>
</form>
<%
endsub

==================================================================构建创建表的SQL语句
subcreate_table()
dimsql,i,primarykey
onerrorresumenext
sql=CREATETABLE[&request(table_name)&](
fori=1torequest(i)
sql=sql&[&request(field_name)(i)&]&request(field_type)(i)
ifrequest(field_size)(i)<>then
sql=sql&(&request(field_size)(i)&)
endif
ifrequest(null)(i)=NOT_NULLthen
sql=sql&notnull
endif
ifrequest(autoincrement)(i)=自动编号then
sql=sql&identity
endif
ifrequest(primarykey)(i)=primarykeythen
primarykey=request(field_name)(i)
endif
ifprimarykey<>then
sql=sql&,
endif
next
ifprimarykey<>then
sql=sql&primarykey([&primarykey&])
endif
sql=sql&)
sql=replace(sql,(),)构建空表
response.redirect?key=sql&sql=&sql
endsub


==================================================================修改表名或字段名2006-09-08
subreobj()
onerrorresumenext
Dimmydb,mytable,tablename
tablename=request(tablename)
Setmydb=Server.CreateObject(ADOX.Catalog)
mydb.ActiveConnection=conn

ifrequest(obj)=fieldthen修改字段名
dimfieldsname,newfieldsname
fieldsname=request(fieldsname)
newfieldsname=request(newfieldsname)
Setmytable=Server.CreateObject(ADOX.Table)
Setmytable=mydb.Tables(tablename)
endif

ifrequest(obj)=tablethen修改表名
dimnewtablename
newtablename=request(newtablename)
mydb.Tables(tablename).Name=newtablename
endif

iferr<>0then
echoerr.description
echo<inputtype=buttonname=okvalue=返回onClick=javascript:history.go(-1)>
exitsub
endif

ifrequest(obj)=fieldthen
response.Redirect?key=view&table_name=&tablename
else
response.Redirect?key=view&table_name=&newtablename
endif

endsub

==================================================================查看表结构函数
subview(table_name)
table_name=表名称
dimrs,sql,table,primary,primarykey,i,editstr,typs
onerrorresumenext
table=table_name
Setprimary=Conn.OpenSchema(adSchemaPrimaryKeys,Array(empty,empty,table))
ifprimary(COLUMN_NAME)<>then
primarykey=primary(COLUMN_NAME)
endif
primary.Close
Setprimary=Nothing

%>

<scriptlanguage=javascript>
functiontable_delete()
{
if(confirm(确认删除该记录吗?该操作将不可撤销!!!))
returntrue;
else
returnfalse;
}
</script>

<fontcolor=red>表:<%=table_name%></font><inputtype=buttonvalue=刷新本页onClick=javascript:location.reload()><br><br>
<%ifrequest(key)=editfidlevithencalleditfidlevi()%>
<tablewidth=600border=0cellpadding=1cellspacing=1bgcolor=#CCCCCC>
<tr>
<tdwidth=125height=20align=center>字段名</td>
<tdwidth=110align=center>类型</td>
<tdwidth=83align=center>设定大小</td>
<tdwidth=48align=center>允许空</td>
<tdwidth=76align=center>自动编号</td>
<tdwidth=54align=center>主键</td>
<tdwidth=82align=center>执行操作</td>
</tr>
<%
sql=SELECT*FROM[&table_name&]
Setrs=Conn.Execute(sql)
iferr=0then
Fori=0tors.fields.count-1
%>
<tr>
<tdheight=20align=left><%=rs(i).name%></td>
<tdalign=left><%=typ(rs(i).type)%></td>
<tdalign=center><%=rs(i).definedsize%></td>
<tdalign=center><%=iif((rs(i).AttributesandadFldIsNullable)=0,No,Yes)%></td>
<tdalign=center><%=iif(rs(i).Properties(ISAUTOINCREMENT)=True,是,否)%></td>
<tdalign=center><%=iif(rs(i).name=primarykey,是,否)%></td>
<tdalign=center>
<ahref=?key=editfidlevi&fidle=<%=rs(i).name%>&table_name=<%=table_name%>&fidletype=<%=typ(rs(i).type)%>>修改</a>
<ahref=?key=sql&sql=altertable[<%=table_name%>]drop[<%=rs(i).name%>];onClick=returntable_delete();>删除</a>
</td>
</tr>
<%
editstr=editstr&<optionvalue=&rs(i).name&>&rs(i).name&</option>
next
%>
</table>
<br>
<ahref=?key=tosql&strt=0&table_name=<%=table_name%>>导出表结构</a>
<ahref=?key=sql&sql=select*from<%=table_name%>&table_name=<%=table_name%>&primarykey=<%=primarykey%>>浏览表记录</a>
<ahref=?key=sql&sql=DROPTABLE<%=table_name%>onClick=returntable_delete();>删除表</a>
<inputtype=textname=newtablenamesize=20value=<%=table_name%>>
<inputtype=buttonvalue=修改表名onClick=location.href=?key=reobj&obj=table&tablename=<%=table_name%>&newtablename=+newtablename.value>
<br><br>
<%
判断是否有主键
ifprimarykey=then
echo<fontcolor=red>该表没有主。


评论


亲,登录后才可以留言!