• 关于asp的数据处理函数




    第一次使用博客,发布一个数据处理函数,欢迎批评指正
    '-------------------------------------------
    'strSQL:标准的SQL语句
    'arrList:存放数据的二维数组
    'ActionType:操作类型,0为增加、删除数据,1 为读取数据
    '------------------------------------------

    Function ActionDB(strSQL, arrList, ActionType)
        On Error Resume Next
        Dim objConn, objRS
        Dim strConnection

       
    Set objConn = Server.CreateObject("ADODB.Connection")
        objConn.Open Application("connstr")    'Application("connstr") 为 数据库连接字符串
        If Err.Number <> 0 then
            Response.write "<br><br><div align='center'>数据库连接错误!请检查数据库连接。</div>"
            Response.end
        End  if

        Select Case ActionType
              Case 0
                   objConn.Execute strSQL
                    If Err.Number = 0 then
                         ActionDB = True
                    Else
                         ActionDB = False
                    End If
         Case 1
                   Set objRS = Server.CreateObject("ADODB.RecordSet")
                   objRS.CursorLocation = 3
                   Set ObjRS = objConn.Execute(strSQL)
                   If Not objRS.Eof then
                       arrList = objRs.GetRows
                       ActionDB = True
                    End if
                    objRS.Close
                    Set objRS = Nothing
                    If Err.Number > 0 then ActionDB = False
        Case Else
                   ActionDB = False
        End Select

        objConn.Close
        Set objConn = Nothing
     End Function


     

  • 相关阅读:
    Codeforces 271 Div 2 B. Worms
    Codeforces 271 Div 2 A Keyboard
    CSU 1333 Funny Car Racing (最短路)
    CSU 1337 搞笑版费马大定理(2013湖南省程序设计竞赛J题)
    CSU 1328 近似回文词(2013湖南省程序设计竞赛A题)
    HDU 5033 Building
    HDU 1058 Humble Numbers(离线打表)
    HDU 5047 Sawtooth(大数模拟)上海赛区网赛1006
    HDU 5053 the Sum of Cube
    MySQL练习-employees数据库(二)
  • 原文地址:https://www.cnblogs.com/stronger/p/206494.html
Copyright © 2020-2023  润新知