<% ' Option Explicit ' ============================== ' 全局变量 ' Dim objConn ' ============================= ' 数据库连接 ' Sub SetConn () db="/manager/data/pantone.asp" strconn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&db&"") Set objConn = Server.CreateObject ("ADODB.Connection") objConn.Open strConn If Err.number <> 0 Then Response.Write "" Response.End End If End Sub Sub ClearConn () objConn.Close Set objConn = Nothing End Sub ' ============================== ' 添加类别 ' Function AddTypeInfo (strTableName, strContentName, strDescription) If Len (strTableName) <> 0 and Len (strContentName) <> 0 Then Dim strSQL strSQL = "Insert Into " & strTableName & " Values ('" & strContentName & "', '" & strDescription & "')" AddTypeInfo = ExecSQL (strSQL) Else AddTypeInfo = False End If End Function ' ============================ ' 更改类别 ' Function UpdateTypeInfo (strTableName, strContentName, strDescription, iKeyword) If Len (strTableName) <> 0 And Len (strContentName) <> 0 And IsNumeric (iKeyword) then Dim strSQL strSQL = "Update " & strTableName & " Set sName = '" & strContentName & "', sDescription = '" & strDescription & "' where ID = " & iKeyword & "" UpdateTypeInfo = ExecSQL (strSQL) Else UpdateTypeInfo = ExecSQL (strSQL) End If End Function ' =========================== ' 执行数据库连接 ' Function ExecSQL (strSQL) If Len (strSQL) <> 0 Then objConn.Execute (strSQL) If Err.number <> 0 then ExecSQL = False Else ExecSQL = True End If Else ExecSQL = False End If End Function ' 错误处理 Sub ErrHandler (ErrorNo) Select case ErrorNo Case 0 strSuccMessage = "添加成功" strErrMessage = "添加成功" Case 1 strSuccMessage = "修改成功" strErrMessage = "修改成功" Case 2 strSuccMessage = "删除成功" strErrMessage = "删除成功" End Select End Sub %>