⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 db.asp

📁 WAPmo手机网站管理平台是一款创建与管理维护WAP网站的的软件产品
💻 ASP
📖 第 1 页 / 共 2 页
字号:
        ret = "RAND()"
    End Select
    Random = ret
End Function

Public Function Column(ByVal strName, ByVal intType, ByVal intSize, ByVal vtValue, ByVal blnEmpty)
    Dim tmp, arr(4)
    Select Case intType
    Case adTinyInt, adSmallInt, adInteger, adBigInt, adCurrency
        tmp = "$0 $1 $4 NULL"
    Case Else
        If vtValue = "" Then
            tmp = "$0 $1($2) $4 NULL"
        Else
            tmp = "$0 $1($2) DEFAULT $3 $4 NULL"
        End If
    End Select
    arr(0) = strName
    arr(1) = GetColumnType(intType)
    arr(2) = intSize
    arr(3) = vtValue
    arr(4) = IIf(blnEmpty, "", "NOT")
    Column = str_format(tmp, arr)
End Function

Public Function Column2(ByVal intType, ByVal intSize, ByVal vtValue, ByVal blnEmpty)
    Dim tmp, arr(3)
    Select Case intType
    Case adTinyInt, adSmallInt, adInteger, adBigInt, adCurrency
        tmp = "$0 $3 NULL"
    Case Else
        If vtValue = "" Then
            tmp = "$0($1) $3 NULL"
        Else
            tmp = "$0($1) DEFAULT $2 $3 NULL"
        End If
    End Select
    arr(0) = GetColumnType(intType)
    arr(1) = intSize
    arr(2) = vtValue
    arr(3) = IIf(blnEmpty, "", "NOT")
    Column2 = str_format(tmp, arr)
End Function

Public Function GetColumnType(ByVal intType)
    Dim ret
    Select Case intType
    Case adChar
        ret = "CHAR"
    Case adVarChar
        ret = "VARCHAR"
    Case adLongVarChar
        Select Case intDataType
        Case adAccess, adSQLServer
            ret = "TEXT"
        Case adOracle
            ret = "LONG"
        Case adMySQL
            ret = "LONGTEXT"
        End Select
    Case adWChar
        If intDataType = adMySQL Then
            ret = "CHAR"
        Else
            ret = "NCHAR"
        End If
    Case adVarWChar
        If intDataType = adMySQL Then
            ret = "VARCHAR"
        Else
            ret = "NVARChAR"
        End If
    Case adLongVarWChar
        Select Case intDataType
        Case adAccess, adSQLServer
            ret = "NTEXT"
        Case adOracle
            ret = "LONG"
        Case adMySQL
            ret = "LONGTEXT"
        End Select
    Case adInteger
        ret = "INT"
    Case adTinyInt
        ret = "TINYINT"
    Case adSmallInt
        ret = "SMALLINT"
    Case adDouble
        If intDataType = adSQLServer Then
            ret = "FLOAT"
        Else
            ret = "DOUBLE"
        End If
    Case adDecimal
        ret = "DECIMAL"
    Case adNumeric
        ret = "NUMERIC"
    Case adCurrency
        If intDataType = adSQLServer Then
            ret = "MONEY"
        Else
            ret = "DOUBLE"
        End If
    End Select
    GetColumnType = ret
End Function

Public Function GetIdentity(ByVal strTable)
    Dim strSQL
    Select Case intDataType
    Case adAccess, adSQLServer
        strSQL = "SELECT @@IDENTITY FROM $(Table)"
    Case adOracle
        strSQL = "SELECT $(Table)_SEQ FROM DUAL"
    Case adMySQL
        strSQL = "SELECT LAST_INSERT_ID()"
    End Select
    strSQL = Replace(strSQL, "$(Table)", strTable)
    GetIdentity = atol(GetRow(strSQL))
End Function

Public Function AddColumn(ByVal strTable, ByVal strColumn, ByVal strDefine)
    Dim strSQL
    strSQL = "ALTER TABLE $0 ADD $1 $2"
    AddColumn = SafeExec(str_format(strSQL, Array(strTable, strColumn, strDefine)))
End Function

Public Function RenameColumn(ByVal strTable, ByVal strOld, ByVal strNew, ByVal strDef)
    Dim strSQL
    If intDataType = adAccess Then
        RenameColumn = AccessRenameColumn(strTable, strOld, strNew)
    Else
        Select Case intDataType
        Case adSQLServer
            strSQL = "SP_RENAME '$0.$1','$2','COLUMN'"
        Case adOracle
            strSQL = "ALTER TABLE $0 CHANGE $1 $2"
        Case adMySQL
            strSQL = "ALTER TABLE $0 CHANGE $1 $2 $3"
        End Select
        RenameColumn = SafeExec(str_format(strSQL, Array(strTable, strOld, strNew, strDef)))
    End If
End Function

Private Function AccessRenameColumn(ByVal strTable, ByVal strOld, ByVal strNew)
    On Error Resume Next
    Dim objCat, objTab
    Set objCat = Server.CreateObject("ADOX.Catalog")
    objCat.ActiveConnection = ActiveConnection
    Set objTab = objCat.Tables(strTable)
    objTab.Columns(strOld).Name = strNew
    Set objTab = Nothing
    Set objCat = Nothing
    AccessRenameColumn = CBool(Err.Number = 0)
End Function

Public Function DropColumn(ByVal strTable, ByVal strColumn)
    Dim strSQL
    If intDataType = adSQLServer Then
        strSQL = "SP_DELETEFIELD '$0','$1',1"
    Else
        strSQL = "ALTER TABLE $0 DROP COLUMN $1"
    End If
    DropColumn = SafeExec(str_format(strSQL, Array(strTable, strColumn)))
End Function

Public Function DropIndex(ByVal strTable, ByVal strIndex)
    Dim strSQL
    If intDataType = adSQLServer Then
        strSQL = "DROP INDEX $0.$1"
    Else
        strSQL = "DROP INDEX $1 ON $0"
    End If
    DropIndex = SafeExec(str_format(strSQL, Array(strTable, strIndex)))
End Function

Public Function ResetColumn(ByVal strTable, ByVal strColumn, ByVal strDefine)
    Dim strSQL
    If intDataType = adAccess Then
        AddColumn strTable, strColumn & "_T", strDefine
        SafeExec str_format("UPDATE $0 SET $1_T=$1", Array(strTable, strColumn))
        DropColumn strTable, strColumn
        ResetColumn = RenameColumn(strTable, strColumn & "_T", strColumn, strDefine)
    Else
        Select Case intDataType
        Case adSQLServer
            strSQL = "ALTER TABLE $0 ALTER COLUMN $1 $2"
        Case adOracle
        Case adMySQL
            strSQL = "ALTER TABLE $0 MODIFY $1 $2"
        End Select
        ResetColumn = SafeExec(str_format(strSQL, Array(strTable, strColumn, strDefine)))
    End If
End Function

Public Function RenameTable(ByVal strOld, ByVal strNew)
    Dim strSQL
    If intDataType = adAccess Then
        RenameTable = AccessRenameTable(strOld, strNew)
    Else
        Select Case intDataType
        Case adSQLServer
            strSQL = "SP_RENAME '$0','$1','OBJECT'"
        Case adOracle
            strSQL = "RENAME $0 TO $1"
        Case adMySQL
            strSQL = "ALTER TABLE $0 RENAME $1"
        End Select
        RenameTable = SafeExec(str_format(strSQL, Array(strOld, strNew)))
    End If
End Function

Private Function AccessRenameTable(ByVal strOld, ByVal strNew)
    On Error Resume Next
    Dim objCat
    Set objCat = Server.CreateObject("ADOX.Catalog")
    objCat.ActiveConnection = ActiveConnection
    objCat.Tables(strOld).Name = strNew
    Set objCat = Nothing
    AccessRenameTable = CBool(Err.Number = 0)
End Function

'XML Extension
Public Function SQLToXML(ByVal strSQL, ByVal strParent, ByVal strChild)
    Dim rs
    Set rs = Exec2(strSQL)
    Set SQLToXML = RecordToXML(rs, adGetRowsRest, strParent, strChild)
    rs.Close
    Set rs = Nothing
End Function

Public Function newInstance()
    Set newInstance = New ImplMocomUtilDB
End Function
End Class
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -