Ask a Question related to ASP Database, Design and Development.
-
Brynn #1
/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
-
Aaron Bertrand [MVP] #2
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



Reply With Quote

