" & vbCrlf Do While Not rsRecordset.EOF Response.Write "
       
Abundant Technologies - IT Consulting Experts

 Source Code Library

 Code Details

 
<% ' 'VBScript Function Library ' ' '************************************************************************************ '* Comments: Open the database connection '* '* Parameters: ADOLib_Conn - the connection variable '* '* Requirements: '* '* Returns: nothing '************************************************************************************ Function ADOLib_OpenDB(ADOLib_Conn) On Error Resume Next Set ADOLib_Conn = Server.CreateObject("ADODB.Connection") ADOLib_Conn.ConnectionTimeout = Application("ConnectionTimeout") ADOLib_Conn.CommandTimeout = Application("CommandTimeout") ADOLib_Conn.Open Application("ConnectionString"), Application("RuntimeUserName"), Application("RuntimePassword") If Err.number = 0 Then ADOLib_OpenDB = True Else ADOLib_OpenDB = False End IF End Function '************************************************************************************ '* Comments: Close the database connection and destroy connection object '* '* Parameters: ADOLib_Conn - the connection variable '* '* Requirements: '* '* Returns: nothing '************************************************************************************ Function ADOLib_CloseDB(ADOLib_Conn) ADOLib_Conn.Close Set ADOLib_Conn = Nothing End Function '************************************************************************************ '* Comments: Used to get back the first field of the first row '* '* Parameters: strSQL - The connection string the id should be first '* '* Requirements: '* '* Returns: String holding the first field of the first row. '************************************************************************************ Function ADOLib_ReturnFirstField(strSQL, ADOLib_Conn) Set rsRecordset = Server.CreateObject("ADODB.Recordset") rsrecordset.CursorLocation = adUseClient rsRecordset.Open strSQL, ADOLib_Conn, adOpenStatic, adLockReadOnly If Not rsRecordset.EOF Then ADOLib_RETURNFIRSTFIELD = rsRecordset(0) Else ADOLib_RETURNFIRSTFIELD = 0 End If rsRecordset.Close End Function '************************************************************************************ '* Comments: Used to fill session variables with query info '* '* Parameters: strSQL - The connection string the id should be first '* '* Requirements: '* '* Returns: True if ok, false if not. '************************************************************************************ Function ADOLib_FillSession(strSQL, ADOLib_Conn) Set rsRecordset = Server.CreateObject("ADODB.Recordset") rsrecordset.CursorLocation = adUseClient rsRecordset.Open strSQL, ADOLib_Conn, adOpenStatic, adLockReadOnly If Not rsRecordset.EOF Then For Each sField in rsRecordset.Fields Session(sField.Name) = sField.value Next Else For Each sField in rsRecordset.Fields Session(sField.Name) = "" Next End If rsRecordset.Close End Function '************************************************************************************ '* Comments: Used to write a table with all the query info '* '* Parameters: strSQL - The connection string the id should be first '* '* Requirements: '* '* Returns: True if ok, false if not. '************************************************************************************ Function ADOLib_BuildTreeView(strSQL, ADOLib_Conn) Dim strFirst,strSecond,strThird Set rsRecordset = Server.CreateObject("ADODB.Recordset") rsrecordset.CursorLocation = adUseClient rsRecordset.Open strSQL, ADOLib_Conn, adOpenStatic, adLockReadOnly 'response.write "
    " Do While Not rsRecordset.EOF If strFirst <> rsRecordset(0) Then 'Response.Write "
      + " If strFirst <> "" Then response.write "
      " End If Response.Write "" & rsRecordset(0) response.write "" End If If strSecond <> rsRecordset(1) Then 'Response.Write "
      + " 'Response.Write "
        + " Response.Write "
         " Response.Write rsRecordset(1) & "
        " End IF 'Response.Write "" End If If strSecond <> rsRecordset(1) AND strSecond <> "" Then 'Response.Write "
      " End IF strFirst = rsRecordset(0) strSecond = rsRecordset(1) strThird = rsRecordset(2) rsRecordset.MoveNext Loop rsRecordset.Close End Function '************************************************************************************ '* Comments: Used to write a table with all the query info '* '* Parameters: strSQL - The connection string the id should be first '* '* Requirements: '* '* Returns: True if ok, false if not. '************************************************************************************ Function ADOLib_BuildTable(strSQL, ADOLib_Conn, strColumnWidths, iBorder) Set rsRecordset = Server.CreateObject("ADODB.Recordset") rsrecordset.CursorLocation = adUseClient rsRecordset.Open strSQL, ADOLib_Conn, adOpenStatic, adLockReadOnly Response.Write "" & vbCrlf Response.Write "" & vbCrlf For i = 1 To rsRecordset.Fields.Count - 1 Response.Write "" & vbCrlf Next 'Close the Header of the table Response.Write "" & vbCrlf Do While Not rsRecordset.EOF Response.Write "" & vbCrlf For i = 1 To rsRecordset.Fields.Count - 1 Response.Write "" & vbCrlf Next Response.Write "" & vbCrlf rsRecordset.MoveNext Loop Response.Write "
      " & rsRecordset.Fields.Item(0).Name & "" & rsRecordset.Fields.Item(i).Name & "
      " & rsRecordset(0) & "" & rsRecordset(i) & "
      " & vbCrlf Response.Write "" & vbCrlf rsRecordset.Close End Function '************************************************************************************ '* Comments: Used to write the Data From a form to a table '* '* Parameters: strSQL - The connection string '* '* '* Requirements: '* '* Returns: Nothing '************************************************************************************ Function ADOLib_SaveFields(strSQL, ADOLib_Conn, strIdentity) Set rsRecordset = Server.CreateObject("ADODB.Recordset") rsRecordset.Open strSQL, ADOLib_Conn, adOpenForwardOnly, adLockOptimistic 'return the data If rsRecordset.EOF then rsRecordset.AddNew End If For Each sField in rsRecordset.Fields 'Loop Through the recordset values and match the field names 'Autonumber = 16 'Text field = 234 'Response.write sfield.name If sField.Attributes <> 16 AND Request.Form(sField.Name) <> "" OR sField.Attributes = 234 then sField.Value = Request.Form(sField.Name) ElseIf sField.Attributes <> 16 AND sField.Attributes <> 24 AND sField.Value <> "" Then 'Response.Write sField.name 'Response.Write sField.Attributes sField.Value = Null End If Next rsRecordset.Update If strIdentity <> "" Then Session("strIdentity") = rsRecordset(strIdentity) End If rsRecordset.Close ADOLib_SaveFields = true End Function '************************************************************************************ '* Comments: Used to Verify the user information and put the info into session '* variables. '* '* Parameters: strSQL - Make sure to filter by email and password. '* '* Requirements: '* '* Returns: True if ok, false if not. '************************************************************************************ Function ADOLib_VerifyLogin(strSQL, ADOLib_Conn) Dim rsRecordset Set rsRecordset = Server.CreateObject("ADODB.Recordset") rsrecordset.CursorLocation = adUseClient rsRecordset.Open strSQL, ADOLib_Conn, adOpenStatic, adLockReadOnly If Not rsRecordset.EOF Then 'The user has entered a correct login and password! 'Set the session varibles! Session("LoginID") = rsRecordset(0) Session("MemberID") = rsRecordset(1) ADOLib_VERIFYLOGIN = TRUE Else ADOLib_VERIFYLOGIN = FALSE End If rsRecordset.Close End Function '************************************************************************************ '* Comments: Used to write the guts of Select on a webpage '* '* Parameters: strSQL - The connection string the id should be first '* Optional strFirstValue - If you want a custom value index = -1 '* '* Requirements: '* '* Returns: True if ok, false if not. '************************************************************************************ Function ADOLib_BuildSelect(strSQL, ADOLib_Conn, strFirstValue, strSelected) Dim rsRecordset 'Use the first value if needed If strFirstValue <> "" Then Response.Write "" End If Set rsRecordset = Server.CreateObject("ADODB.Recordset") rsRecordset.CursorLocation = adUseClient rsRecordset.Open strSQL, ADOLib_Conn, adOpenStatic, adLockReadOnly Do While Not rsRecordset.EOF If rsRecordset(0)= strSelected Then Response.Write "" & vbCrlf rsRecordset.MoveNext Loop rsRecordset.Close End Function '************************************************************************************ '* Comments: Used to write multiple tables with all the query info '* '* Parameters: strSQL - The connection string the id should be first '* '* Requirements: '* '* Returns: True if ok, false if not. '************************************************************************************ Function ADOLib_BuildTables(strSQL, ADOLib_Conn, strColumnWidths, iBorder, strSQL2, iColumn) Set rsRecordset = Server.CreateObject("ADODB.Recordset") rsRecordset.Open strSQL, ADOLib_Conn 'Close the Header of the table Response.Write "
" & vbCrlf Response.Write "" & vbCrlf For ii = 1 To rsRecordset.Fields.Count - 1 If cInt(ii) <> cInt(iColumn) then Response.Write "" & vbCrlf End If Next Response.Write "" & vbCrlf For i = 1 To rsRecordset.Fields.Count - 1 If cInt(i) = cInt(iColumn) then Response.Write "" & vbCrlf Response.Write "" & vbCrlf 'Get the recordset strSQL1 = strSQL2 & " Where " & rsRecordset(i).name & " = " & rsRecordset(i) Response.Write ADOLib_BUILDTABLE(strSQL1,"0","0") Else Response.Write "" & vbCrlf End If Next Response.Write "" & vbCrlf rsRecordset.MoveNext Loop rsRecordset.Close Response.Write "
" & rsRecordset.Fields.Item(0).Name & "" & rsRecordset.Fields.Item(ii).Name & "
" & rsRecordset(0) & "

Available Colors:

" & rsRecordset(i) & "
" & vbCrlf End Function '************************************************************************************ '* Comments: Used to write the images associated with a pre-loaded image box '* '* Parameters: strSQL - The connection string the id should be first '* Example "Select 'iColorID' + convert(varchar(20),iColorID), txtColorPicture From lstColor" '* '* Requirements: '* '* Returns: True if ok, false if not. '************************************************************************************ Function ADOLib_LoadImages(strSQL, ADOLib_Conn) Set rsRecordset = Server.CreateObject("ADODB.Recordset") rsRecordset.Open strSQL, ADOLib_Conn 'return the data Do While Not rsRecordset.EOF 'Declare the pre-load image Response.Write " " & rsrecordset(0) & " = new Image();" & vbCrlf 'Connect the image to the declaired pre-load Response.Write " " & rsrecordset(0) & ".src = """ & rsRecordset(1) & """;" & vbCrlf rsRecordset.MoveNext Loop rsRecordset.Close End Function '************************************************************************************ '* Comments: Format telephone numbers '* '* Parameters: strPhoneNum - The phone number '* '* Requirements: '* '* Returns: Formatted telephone number '************************************************************************************ Function ADOLib_FormatTelephone(ByVal strPhoneNum) Dim varLength Dim tmpNumber tmpNumber = strPhoneNum varLength = Len(tmpNumber) If varLength = 10 Then If IsNumeric(varLength) Then ADOLib_FormatTelephone = "(" ADOLib_FormatTelephone = ADOLib_FormatTelephone & Mid(tmpNumber, 1, 3) ADOLib_FormatTelephone = ADOLib_FormatTelephone & ") " ADOLib_FormatTelephone = ADOLib_FormatTelephone & Mid(tmpNumber, 4, 3) ADOLib_FormatTelephone = ADOLib_FormatTelephone & "-" ADOLib_FormatTelephone = ADOLib_FormatTelephone & Mid(tmpNumber, 7, 4) End If ElseIF varLength = 7 Then If IsNumeric(varLength) Then ADOLib_FormatTelephone = Mid(tmpNumber, 1, 3) ADOLib_FormatTelephone = ADOLib_FormatTelephone & "-" ADOLib_FormatTelephone = ADOLib_FormatTelephone & Mid(tmpNumber, 4, 4) End If End If End Function '************************************************************************************ '* Comments: UnFormat telephone numbers '* '* Parameters: strPhoneNum - The phone number '* '* Requirements: '* '* Returns: Unformatted number '************************************************************************************ Function ADOLib_UnFormatTelephone(ByVal strPhoneNum) Dim varLength Dim tmpNumber Dim i tmpNumber = strPhoneNum varLength = Len(tmpNumber) For i = 0 to varLength If IsNumeric(Mid(tmpNumber, i, 1)) Then ADOLib_UnFormatTelephone = ADOLib_UnFormatTelephone & Mid(tmpNumber, i, 1) End If Next End Function '************************************************************************************ '* Comments: User Logout '* '* Parameters: '* '* Requirements: '* '* Returns: '************************************************************************************ Function ADOLib_LogOut() 'Set the session varibles! Session("LoginID") = "" Session("MemberID") = "" End Function %>
Mail To: info@3pc.com