/coolpier_scripts/_database_tools.asp

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default /coolpier_scripts/_database_tools.asp

    I will be placing instructions on how to use my _database_tools.asp
    script on my site by Friday. I am placing my code here, but will also
    have code view available on my website by Friday.

    Brynn
    [url]www.coolpier.com[/url]

    -- _database_tools.asp --

    <!-- Code Developer: Brynn Curry -- [url]www.coolpier.com[/url] -- checkout my
    websites instructions, examples, and disclaimers before using this
    code.-->

    <!-- #include virtual="/coolpier_scripts_data/_config.asp" -->
    <% '// See [url]http://www.coolpier.com[/url] for instructions, examples, and
    disclaimer before using this code.

    Dim cp_ConnString: cp_ConnString = cp_ConnectionString
    Dim cp_DBConnection, cp_ConnCheck: cp_ConnCheck = 0



    '//Subroutine that executes a sql statement which DOES NOT return a
    recordset
    '//**insert/update/delete -or- stored procedures that do not
    return a recordset**
    Sub cp_SqlExecute(cp_SqlStatement, cp_ConnStateLeft)
    If cp_ConnCheck = 0 Then
    Set cp_DBConnection = CreateObject("ADODB.Connection")
    cp_DBConnection.Open(cp_ConnString)
    cp_ConnCheck = 1
    End If

    cp_DBConnection.Execute cp_SqlStatement, ,129

    If cp_ConnStateLeft = "close" or cp_ConnStateLeft = "" or
    cp_ConnStateLeft = 0 Then
    cp_DBConnection.Close
    Set cp_DBConnection = Nothing
    cp_ConnCheck = 0
    End If
    End Sub



    '//Subroutine that executes a sql statement which DOES return a
    recordset
    '//**select -or- stored procedures that return a recordset**
    Dim cp_PageCount
    Function cp_SqlArray(cp_SqlStatement, cp_PageNumber,
    cp_RecordsPerPage, cp_SqlStatement_Count, cp_ConnStateLeft)
    If cp_ConnCheck = 0 Then
    Set cp_DBConnection = CreateObject("ADODB.Connection")
    cp_DBConnection.Open(cp_ConnString)
    cp_ConnCheck = 1
    End If

    Dim cp_Recordset
    Set cp_Recordset = cp_DBConnection.Execute(cp_SqlStatement)
    If Not cp_Recordset.EOF Then
    If cp_PageNumber = "" Then
    cp_SqlArray = cp_Recordset.GetRows()
    Else

    cp_Recordset.Move(cp_RecordsPerPage*(cp_PageNumber-1))
    cp_SqlArray =
    cp_Recordset.GetRows(cp_RecordsPerPage)
    cp_Recordset.Close: Set cp_Recordset =
    Nothing
    Set cp_Recordset =
    cp_DBConnection.Execute(cp_SqlStatement_Count)
    cp_PageCount = CInt((cp_Recordset(0) /
    cp_RecordsPerPage)+.5)
    End If
    End If
    cp_Recordset.Close: Set cp_Recordset = Nothing

    If cp_ConnStateLeft = "close" or cp_ConnStateLeft = "" or
    cp_ConnStateLeft = 0 Then
    cp_DBConnection.Close
    Set cp_DBConnection = Nothing
    cp_ConnCheck = 0
    End If
    End Function



    '//Extra Function - Single Quote Fix For SQL Statements
    Function cp_qfx(cp_TheTextToFix)
    cp_qfx = Replace(cp_TheTextToFix, "'", "''")
    End Function
    %>
    Brynn
    [url]www.coolpier.com[/url]

    I participate in the group to help give examples of code.
    I do not guarantee the effects of any code posted.
    Test all code before use!
    Brynn Guest

  2. #2

    Default Re: /coolpier_scripts/_database_tools.asp

    > Function cp_qfx(cp_TheTextToFix)

    Personally, I find the "shorthand" function names very awkward to type and
    remember.

    It is much less painful to remember and type out the replace function than
    to type these underbar-prefixed shorthand names.


    Aaron Bertrand [MVP] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139