📄 admin_dbtools.asp
字号:
Public Property Let DbPWD(s)
Select Case sConnType
Case "ODBC" : sConnString = sConnString & "PWD=" & s & ";"
Case "OLEDB" : sConnString = sConnString & "Password=" & s & ";"
End Select
End Property
Public Property Let DbCatelog(s)
Select Case iDbType
Case 0
Case 1
Select Case sConnType
Case "ODBC" : sConnString = sConnString & "DATABASE=" & s & ";"
Case "OLEDB" : sConnString = sConnString & "DATABASE=" & s & ";"
End Select
End Select
End Property
Public Property Get ConnString
ConnString = oConn.ConnectionString
End Property
Public Property Get isActive
isActive = bDbActived
End Property
Public Function Open()
on error Resume Next
If Request.ServerVariables("REQUEST_METHOD")<>"POST" Then Exit Function
oConn.ConnectionString = sConnString
oConn.Open()
If Err Then
sLastErrDescription = Err.Description
Err.Clear()
Exit Function
End If
bDbActived = true
End Function
Public Property Get Conn
Set Conn = oConn
End Property
Public Property Get GetLastError
GetLastError = sLastErrDescription
End Property
Public Function GetDbObject()
Dim rsObj
ReDim aObjList(-1)
If UBound(aObjList)>0 Then GetDbObject = aObjList : Exit Function
Set rsObj = oConn.openSchema(20)
rsObj.Filter = "TABLE_TYPE='TABLE' OR TABLE_TYPE='VIEW'"
Do While Not rsObj.Eof
ReDim Preserve aObjList(UBound(aObjList)+1)
aObjList(UBound(aObjList)) = Array(rsObj("TABLE_NAME").value,rsObj("TABLE_TYPE").value)
rsObj.MoveNext()
Loop
Set rsObj = Nothing
GetDbObject = aObjList
End Function
Public Function doSql(s)
On Error Resume Next
sSqlString = Trim(s)
IF StrComp(Left(sSqlString,6),"SELECT")=0 Then
'Set doSql = doSelect(sSqlString,20,1)
Set doSql = Nothing
Exit Function
Else
oConn.Execute( s )
Set doSql = Nothing
If Err Then
sLastErrDescription = Err.Description
Err.Clear()
Exit Function
End If
sLastErrDescription = "执行成功!"
End If
End Function
Public Function doSelect(sSqlString,iPgSz,iPgNo)
On Error Resume Next
iCurrPage = iPgNo
If Not isNumeric(iCurrPage) Then iCurrPage = 1
If CInt(iCurrPage)<1 Then iCurrPage = 1
Set doSelect = Server.CreateObject("ADODB.Recordset")
doSelect.Open sSqlString,oConn,1,3
If Err Then
sLastErrDescription = Err.Description
Err.Clear()
Set doSelect = Nothing
Exit Function
End If
If Not doSelect.Eof Then
iRecCount = doSelect.RecordCount
doSelect.PageSize = iPgSz
iPageSize = iPgSz
iPageCount = doSelect.PageCount
If CInt(iCurrPage)>CInt(iPageCount) Then iCurrPage = iPageCount
doSelect.AbsolutePage = CInt(iCurrPage)
End If
sLastErrDescription = "执行成功!"
End Function
Public Function GetPrimaryKey(sTName)
on error Resume Next
Dim rsPrimary
GetPrimaryKey = ""
Set rsPrimary = oConn.OpenSchema(adSchemaPrimaryKeys,Array(Empty,Empty,sTblName))
If Not rsPrimary.Eof Then GetPrimaryKey = rsPrimary("COLUMN_NAME")
Set rsPrimary = Nothing
End Function
Public Function GetColumnInfo(sTName,sCName)
Set GetColumnInfo = oConn.OpenSchema(adSchemaColumns,Array(Empty,Empty,sTName,sCName))
End Function
Public Property Get PageCount
PageCount = iPageCount
End Property
Public Property Get RecCount
RecCount = iRecCount
End Property
Public Property Get PageNo
If CInt(iCurrPage) > CInt(iPageCount) Then iCurrPage = iPageCount
PageNo = iCurrPage
End Property
End Class
On Error Resume Next
Dim CCDbT, sTblType, iPageSize
Dim aObjList, sShowBody, iPageNo
Dim sSqlString, sOper, sTblName
sSqlString = Request("sSqlString")
sOper = Request("sOper")
sTblName = Request("sTblName")
sTblType = Request("sTblType")
iPageNo = Request("PageNo")
Set CCDbT = New CC_DBTools
CCDbT.DataBaseType = Request("sDbType")
CCDbT.ConnType = Request("sConnType")
CCDbT.Dbpath = Request("sDbPath")
CCDbT.DbUID = Request("sUID")
CCDbT.DbPWD = Request("sPWD")
CCDbT.DbCatelog = Request("sDbName")
CCDbT.Open()
iPageSize = 10
%>
<!--
'--------------------------------------------------------------------
' COCOON Db Tools Final Release
'
' Copyright (c) 2000-2002 COCOON sTudio.
' [ www.cocoon.6to23.com ]
' 作者: Sunrise _Chen
' 请保留以上信息,谢谢配合。
'--------------------------------------------------------------------
-->
<html>
<head>
<title>COCOON DBTools</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
body,td {
font-family: "Verdana", "Arial", "Helvetica", "sans-serif";
font-size: 9pt;
}
.1BorderTable {
border: 1px solid #666666;
}
.inputText {
width: 100%;
}
.inputButton {
width: 102px;
}
.tdTitle {
color: #FFFFFF;
background-color: #616161;
}
.inputText0Border {
width: 100%;
border: none;
}
-->
</style>
<script language="JavaScript" src="style/CCDbTScript.js"></script>
</head>
<body leftmargin="10" topmargin="14" marginwidth="0" marginheight="0">
<div id="divFieldType" style="position:absolute; left:6px; top:10px; z-index:99;display:none">
<select id="selFieldType" onChange="checkFieldType(this.value,this[this.selectedIndex].sLength)" onBlur='showFieldType(0)' style="width:130">
<OPTION value=TinyInt sLength=1>TinyInt
<OPTION value=SmallInt sLength=1>SmallInt
<OPTION value=Int sLength=1>Int
<OPTION value=BigInt sLength=1>BigInt
<OPTION value=Real sLength=1>Real / Single
<OPTION value=Float sLength=1>Float / Double
<OPTION value=Money sLength=1>Money
<OPTION value=Decimal sLength=1>Decimal
<OPTION value=Numeric sLength=1>Numeric
<OPTION value=Bit sLength=1>Bit
<OPTION value=Variant>Variant
<OPTION value=UniqueIdentifier sLength=1>UniqueIdentifier
<OPTION value=DateTime sLength=1>DateTime
<OPTION value=Char>Char
<OPTION value=VarChar>VarChar
<OPTION value=Text sLength=1>Text
<OPTION value=nChar>nChar
<OPTION value=nVarChar>nVarChar
<OPTION value=nText sLength=1>nText
<OPTION value=TimeStamp sLength=1>TimeStamp
<OPTION value=VarBinary sLength=1>VarBinary
<OPTION value=Image sLength=1>Image
<!--
<OPTION value=DBDate>DBDate
<OPTION value=DBTime>DBTime
<OPTION value=BSTR>BSTR
<OPTION value=Chapter>Chapter
<OPTION value=FileTime>FileTime
<OPTION value=PropVariant>PropVariant
<OPTION value=VarNumeric>VarNumeric
<OPTION value=Array>Array
<OPTION value=UnsignedTinyInt sLength=>UnsignedTinyInt
<OPTION value=UnsignedSmallInt sLength=>UnsignedSmallInt
<OPTION value=UnsignedInt sLength=>UnsignedInt
<OPTION value=UnsignedBigInt sLength=>UnsignedBigInt
<OPTION value=IDispatch>IDispatch
<OPTION value=IUnknown>IUnknown
<OPTION value=Error>Error
<OPTION value=UserDefined>UserDefined
<OPTION value=Empty>Empty
-->
</select>
</div>
<br>
<table width="760" border="0" cellpadding="0" cellspacing="1" class="1BorderTable">
<form method="post" name="formLink" id="formLink">
<tr>
<td width="45" align="center" nowrap class="tdTitle">连接</td>
<td nowrap>
<div id="divLink">
数据库类型
<select name="sDbType" size="1" id="sDbType">
<option value="ACCESS" selected>ACCESS</option>
<option value="MSSQL">SQLServer</option>
</select>
<div style="display:none">
连接类型
<select name="sConnType" size="1" id="sConnType">
<option value="ODBC">ODBC</option>
<option value="OLEDB" selected>OLEDB</option>
</select>
</div>
位置
<input name="sDbPath" type="text" id="sDbPath" size="12">
<span title="输入SQLSERVER的库,Access不需填写">
SQL库
<input name="sDbName" type="text" id="sDbName" size="10">
</span>
用户名
<input name="sUID" type="text" id="sUID" size="8">
密码
<input name="sPWD" type="password" id="sPWD" size="8">
<input type="submit" name="Submit" value="Submit">
</div>
<div id="divLinked" style="display:none">
<input type="text" name="sConnString" style="width:600" readonly="true">
<input type="button" name="Reset" value="重新连接" class="inputButton" onClick="location.href='<%=Request.ServerVariables("URL")%>'">
</div>
</td>
</tr>
</form>
</table>
<script language="JavaScript">
var oFormLink = getObjByID("formLink");
<% If Request.ServerVariables("REQUEST_METHOD")="POST" Then %>
oFormLink.sDbType.value = "<%=String4Js(Request("sDbType"))%>";
oFormLink.sConnType.value = "<%=String4Js(Request("sConnType"))%>";
oFormLink.sDbPath.value = "<%=String4Js(Request("sDbPath"))%>";
oFormLink.sDbName.value = "<%=String4Js(Request("sDbName"))%>";
oFormLink.sUID.value = "<%=String4Js(Request("sUID"))%>";
oFormLink.sPWD.value = "<%=String4Js(Request("sPWD"))%>";
var oDivLink = getObjByID("divLink");
var oDivLinked = getObjByID("divLinked");
<% If Len(CCDbT.GetLastError)>0 Or CCDbT.isActive=true Then %>
oDivLink.style.display = "none";
oDivLinked.style.display = "";
<% Else %>
oDivLink.style.display = "";
oDivLinked.style.display = "none";
<% End If %>
oFormLink.sConnString.value = "<%=String4Js(IIf(Len(CCDbT.GetLastError)<1,CCDbT.ConnString,CCDbT.GetLastError))%>";
<% End If %>
</script>
<table width="760" border="0" cellpadding="0" cellspacing="1" class="1BorderTable">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -