ADODB.Connection error '800a0e78'

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • simonruk1
    New Member
    • Feb 2008
    • 5

    ADODB.Connection error '800a0e78'

    Hi I am new to ASP and I am getting this error:

    ADODB.Connectio n error '800a0e78'

    Operation is not allowed when the object is closed.

    /members/asp/util.asp, line 67


    the code line in the util.asp looks like this:

    Sub CreateVisitorID (dcnDB)

    Dim rsData
    Dim strSQL

    If Request.Cookies ("VisitorID" ) <> "" Then Exit Sub

    strSQL = "INSERT INTO Visitors " & "(VisitDate , Host) " & "VALUES (" & "#" & Date & " " & Time & "#, " & "'"

    If Request.ServerV ariables("REMOT E_HOST") <> "" Then
    strSQL = strSQL & Request.ServerV ariables("REMOT E_HOST")
    Else
    strSQL = strSQL & Request.ServerV ariables("REMOT E_ADDR")
    End IF

    strSQL = strSQL & "')"

    Application.Loc k
    dcnDB.Execute strSQL (this is line 67)
    strSQL = "SELECT Max(VisitorID) FROM Visitors"
    Set rsData = dcnDB.Execute(s trSQL)
    Response.Cookie s("VisitorID" ) = rsData(0)
    Application.Unl ock

    rsData.Close

    End Sub


    Can any please help
  • CroCrew
    Recognized Expert Contributor
    • Jan 2008
    • 564

    #2
    Can you post your connection string (without username and password). Also please let us know the type of database that you are using.

    CroCrew~

    Comment

    • simonruk1
      New Member
      • Feb 2008
      • 5

      #3
      it links to a .mdb file

      this is the full code for the file

      <%
      Option Explicit
      %>
      <!-- #include file=adovbs.inc -->
      <%
      Const ACTION_VALIDATE = "v"
      Const MODE_ADD = "a"
      Const MODE_MODIFY = "m"
      Const MODE_POST = "p"
      Const MODE_REPLY = "r"

      Function OpenDB()
      Dim dcnDB
      Dim strDatabaseLoca tion ' As String
      Dim rsForMem ' As ADODB.Recordset
      Dim strSQL ' As String
      On Error Resume Next

      strDatabaseLoca tion = Server.MapPath( "../../../data/file.mdb")

      Set dcnDB = Server.CreateOb ject("ADODB.Con nection")

      dcnDB.Connectio nString = "Provider=Micro soft.Jet.OLEDB. 4.0;" & "Persist Security Info=False;Data Source=" & strDatabaseLoca tion

      dcnDB.Open

      Set OpenDB = dcnDB

      End Function

      Sub CloseDB(dcnDB)

      dcnDB.Close

      End Sub



      Sub CheckForLogin()

      If Request.Cookies ("MemberID") = "" Then
      Response.Redire ct "../pages/hpage.html"

      End If

      End Sub
      %>
      <%
      Sub CreateVisitorID (dcnDB)

      Dim rsData
      Dim strSQL

      If Request.Cookies ("VisitorID" ) <> "" Then Exit Sub

      strSQL = "INSERT INTO Visitors " & "(VisitDate , Host) " & "VALUES (" & "#" & Date & " " & Time & "#, " & "'"

      If Request.ServerV ariables("REMOT E_HOST") <> "" Then
      strSQL = strSQL & Request.ServerV ariables("REMOT E_HOST")
      Else
      strSQL = strSQL & Request.ServerV ariables("REMOT E_ADDR")
      End IF

      strSQL = strSQL & "')"

      Application.Loc k
      dcnDB.Execute strSQL
      strSQL = "SELECT Max(VisitorID) FROM Visitors"
      Set rsData = dcnDB.Execute(s trSQL)
      Response.Cookie s("VisitorID" ) = rsData(0)
      Application.Unl ock

      rsData.Close

      End Sub

      Sub RecordSearchInf o(dcnDB, strSearch, strSearch1, strSearch2, strSearch3, searchMemID, lngResultCount)
      On Error Resume Next
      Dim strSQL

      CreateVisitorID dcnDB

      strSQL = "INSERT INTO VisitorSearches " & "(VisitorID , SearchTerms, SearchTerms1, SearchTerms2, SearchTerms3, MemID, SearchResults) VALUES (" & Request.Cookies ("VisitorID" ) & ", '" & Replace(strSear ch, "'", "''") & "' , '" & Replace(strSear ch1, "'", "''") & "', '" & Replace(strSear ch2, "'", "''") & "', '" & Replace(strSear ch3, "'", "''") & "', '" & Replace(searchM emID, "'", "''")& "', " & lngResultCount & ")"
      dcnDB.Execute strSQL

      End Sub
      %>

      <%
      Sub MapRequestInfo (dcnDB, MapType, County)

      Dim strSQL

      CreateVisitorID dcnDB

      strSQL = "INSERT INTO MapRequests " & "(VisitorID , MapType, County) VALUES (" & Request.Cookies ("VisitorID" ) & ", '" & Replace (MapType, "'", "''") & "' , '" & Replace(County, "'", "''") & "'" & ")"

      dcnDB.Execute strSQL

      End Sub

      %>

      Comment

      • DrBunchman
        Recognized Expert Contributor
        • Jan 2008
        • 979

        #4
        Hi Simon,

        When you call the sub CreateVisitorID (dcnDB) are you passing in an open database connection? Somewhere prior to calling this sub you must first call the function OpenDB() and assign it to your database connection object. e.g

        Code:
         Dim dcnDB 
        dcnDB = OpenDB()
        CreateVisitorID(dcnDB)
        Hope this helps,

        Dr B

        Comment

        • markrawlingson
          Recognized Expert Contributor
          • Aug 2007
          • 346

          #5
          I would agree with DrBunchman, that is probably where the problem lies.

          However I'd also like to point out that you may want to try changing the sub routine to a function if you're going to be passing it your connection object, or just remove that argument all together and setup your connection object in such a way that it doesn't need to be called or passed through as an argument.

          I've never been able to successfully pass an object as an argument to a Subroutine, but I've been very successful doing this with functions.

          I had a similar problem a few months back and resolved the issue by simply changing the sub to a function. That particular scenario has lead me to believe that subroutines cannot accept an object as an argument, but I could be wrong about that.

          Hope that helps,

          Sincerely,
          Mark

          Comment

          • simonruk1
            New Member
            • Feb 2008
            • 5

            #6
            this is the results.asp page

            <!-- #include file="util.asp" -->
            <%
            Dim dcnDB ' As ADODB.Connectio n
            Dim rsData ' As ADODB.Recordset
            Dim strSQL ' As String
            Dim blnaddedWhere
            Dim blnAddedAnd
            Dim strAddress
            Dim objFSO
            Dim strFile
            Dim strImage
            Const RECORDSPERPAGE = 2
            Dim intPages
            Dim intPageNum
            Dim intCount
            Dim Count
            Dim endrow
            Dim i
            Dim z
            Dim arrPages(10)
            Dim strDataTable
            Dim arrAll()
            Dim v
            Dim y
            Dim x
            Dim intMemID
            Dim arrSQL()
            Dim intCountRecords
            Dim intArrCount
            Dim strSQL1

            SET dcnDB = OpenDB()
            SET rsData = Server.CreateOb ject ("ADODB.Records et")

            If Request("strSQL ") = "" Then

            If Request("search _type") = "coName" Then
            If Request("search Name") <> "" Then
            strSQL = "SELECT * FROM tblMembers WHERE Active=True AND MemName LIKE '%" & Request("search Name") & "%'" & " ORDER By (MemName)"
            Else
            strSQL = "SELECT * FROM tblMembers WHERE Active=True" & " ORDER By (MemName)"
            End if
            Elseif Request("search _type") = "coLocationEngl and" Then

            If Request("area") = "England (all)" Then
            strSQL = "SELECT * FROM tblMembers Where Active=True AND Country = 'ENGLAND'"
            Else
            strSQL = "SELECT * FROM tblMembers WHERE Active=True AND Location ='" & Request("area") & "'" & " ORDER By (MemName)"
            End if

            Elseif Request("search _type") = "coLocationScot land" Then

            If Request("area") = "Scotland (all)" Then
            strSQL = "SELECT * FROM tblMembers WHERE Active=True AND Country = 'SCOTLAND'"
            Else
            strSQL = "SELECT * FROM tblMembers WHERE Active=True AND Location ='" & Request("area") & "'" & " ORDER By (MemName)"
            End if

            Elseif Request("search _type") = "coLocationWale s" Then

            If Request("area") = "Wales (all)" Then
            strSQL = "SELECT * FROM tblMembers WHERE Active=True AND Country = 'WALES'"
            Else
            strSQL = "SELECT * FROM tblMembers WHERE Active=True AND Location ='" & Request("area") & "'" & " ORDER By (MemName)"
            End if

            Elseif Request("search _type") = "coLocation NI" Then

            strSQL = "SELECT * FROM tblMembers WHERE Active=True AND Country = 'N IRELAND'"

            Elseif Request("search _type") = "worldWide" Then

            If Request("area") = "Worldwide (please select)" Then
            strSQL = "SELECT * FROM tblMembers WHERE Active=True"
            Else
            strSQL = "SELECT * FROM tblMembers WHERE Active=True AND Location ='" & Request("area") & "'" & " ORDER By (MemName)"
            End if

            Elseif Request("search _type") = "criteriaLocati on" Then

            strSQL = "SELECT * FROM qryMemAreas" & " WHERE Active=True"

            blnAddedAnd = False

            If Request("acMain ") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & " acMain=True"
            End if
            If Request("idCard ") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "idCard=Tru e"
            End if
            If Request("acManu ") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "acManu=Tru e"
            End if
            If Request("secInH ouse") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "secInHouse=Tru e"
            End if
            If Request("secAir port") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "secAirport=Tru e"
            End if
            If Request("secIT" ) = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "secIT=True "
            End if
            If Request("arc") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "arc=True"
            End if
            If Request("insura nce") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "insurance=True "
            End if
            If Request("baliff s") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "baliffs=Tr ue"
            End if
            If Request("intrud erMain") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "intruderMain=T rue"
            End if
            If Request("carpar k") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "carpark=Tr ue"
            End if
            If Request("intrud erManu") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "intruderManu=T rue"
            End if
            If Request("cashTr ansit") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "cashTransit=Tr ue"
            End if
            If Request("intrud erMon") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "intruderMon=Tr ue"
            End if
            If Request("CCTVSt aff") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "CCTVStaff=True "
            End if
            If Request("invest igations") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "investigations =True"
            End if
            If Request("CCTVMa in") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "CCTVMain=T rue"
            End if
            If Request("keyHol ding") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "keyHolding=Tru e"
            End if
            If Request("CCTVMa nu") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "CCTVManu=T rue"
            End if
            If Request("locksm iths") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "locksmiths=Tru e"
            End if
            If Request("CCTVRe mote") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "CCTVRemote=Tru e"
            End if
            If Request("manned Guard") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "mannedGuard=Tr ue"
            End if
            If Request("closeP rotection") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "closeProtectio n=True"
            End if
            If Request("mariti meSec") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "maritimeSec=Tr ue"
            End if
            If Request("Comms" ) = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "Comms=True "
            End if
            If Request("mobPat rols") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "mobPatrols=Tru e"
            End if
            If Request("recept ion") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "reception=True "
            End if
            If Request("perime terSEInstall") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "perimeterSEIns tall=True"
            End if
            If Request("perime terSEManu") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "perimeterSEMan u=True"
            End if
            If Request("wasteD esc") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "wasteDesc=True "
            End if
            If Request("publis her") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "publisher=True "
            End if
            If Request("consul tantSec") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "consultantSec= True"
            End if
            If Request("recrui tment") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "recruitment=Tr ue"
            End if
            If Request("courtS ec") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "courtSec=T rue"
            End if
            If Request("retail Sec") = "Y" Then


            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "retailSec=True "
            End if
            If Request("crimeP re") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "crimePre=T rue"
            End if
            If Request("storeD ec") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "storeDec=T rue"
            End if
            If Request("dogs") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "dogs=True"
            End if
            If Request("screen ing") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "screening=True "
            End if
            If Request("doorSu pers") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "doorSupers=Tru e"
            End if
            If Request("secAss ") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "secAss=Tru e"
            End if
            If Request("escDel ") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "escDel=Tru e"
            End if
            If Request("secHar dManu") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "secHardManu=Tr ue"
            End if
            If Request("exhibS ec") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "exhibSec=T rue"
            End if
            If Request("survei llance") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "surveillance=T rue"
            End if
            If Request("facsMa n") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "facsMan=Tr ue"
            End if
            If Request("traini ng") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "training=T rue"
            End if
            If Request("fireIn stall") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "fireInstall=Tr ue"
            End if
            If Request("unifor ms") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "uniforms=T rue"
            End if
            If Request("fireMa nu") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "fireManu=T rue"
            End if
            If Request("vehicl eSec") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "vehicleSec=Tru e"
            End if
            If Request("fireMo ni") = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "fireMoni=T rue"
            End if
            If Request("voids" ) = "Y" Then
            If Not blnAddedAnd Then
            strSQL = strSQL & " AND "
            blnAddedAnd = True
            Else
            strSQL = strSQL & " OR "
            End if
            strSQL = strSQL & "voids=True "
            End if

            If Request("Select Location") <> "Location (Please Select)" Then

            If Request("locati on") = "England (all)" Then
            strSQL = strSQL & " AND Country = 'England'"
            Elseif Request("locati on") = "Scotland (all)" Then
            strSQL = strSQL & " AND Country = 'Scotland'"
            Elseif Request("locati on") = "Wales (all)" Then
            strSQL = strSQL & " AND Country = 'Wales'"
            Elseif Request("locati on") = "Northern Ireland (all)" Then
            strSQL = strSQL & " AND Country = 'Northern Ireland' "
            Elseif Request("locati on") = "Scotland (all)" Then
            strSQL = strSQL & " AND Country = 'Scotland'"
            Else
            strSQL = strSQL & " AND Country = '" & Request("Select Location") & "'" & " AND Area ='" & Request("locati on") & "'"
            End if

            End if
            strSQL = strSQL & " ORDER By (MemName)"
            End if
            Else
            strSQL = Request("strSQL ")
            End if

            ' Response.Cookie s("strSQL") = strSQL

            rsData.Open strSQL, dcnDB, adOpenKeyset, adLockOptimisti c

            If rsData.BOF = True AND rsData.EOF = True Then
            rsData.Close
            CloseDB (dcnDB)
            Response.Redire ct "noResults. asp"
            Else


            '----- FILTER OUT DUPLICATE RECORDS ------

            '-------- Get the number of records to ReDim the array
            rsData.Close
            rsData.Open strSQL , dcnDB, adOpenKeyset, adLockOptimisti c
            rsData.MoveLast
            intCountRecords = rsData.RecordCo unt
            rsData.Close

            ReDim arrAll (intCountRecord s)

            rsData.Open strSQL , dcnDB, adOpenKeyset, adLockOptimisti c

            '--------- Fill the array with all records
            y = 0

            Do While Not rsData.EOF
            arrAll(y) = rsData("MemID")
            y = y + 1
            rsData.MoveNext
            Loop

            '==== Already checked for null recordsets - must be at least one
            '-- Load the First MemID
            intMemID = CInt(arrAll(0))

            '-- Assign the first array value to the new filtered array
            ReDim arrSQL(1)
            arrSQL(0) = intMemID

            intArrCount = 0

            x = 1

            '-- First array value 0 already filled so v = 1 OK
            For v = 1 to intCountRecords
            '-- Test to see if next value is the same as last
            If intMemID = arrAll(v) Then
            intMemID = CInt(arrAll(v))
            Else
            '-- Assign subsequent array values
            x = x+1
            ReDim Preserve arrSQL(x)
            arrSQL(x-1) = intMemID
            intMemID = CInt(arrAll(v))
            intArrCount = intArrCount + 1

            End if
            Next

            x = 0

            strSQL = "SELECT * FROM tblMembers WHERE MemID=" & arrSQL(0)

            For x = 1 to intArrCount

            strSQL = strSQL & " OR MemID=" & arrSQL(x)

            Next

            strSQL = strSQL & " ORDER By (MemName)"
            rsData.Close
            CloseDB (dcnDB)
            Response.Redire ct "search_results .asp?strSQL=" & strSQL
            End if

            %>
            Last edited by markrawlingson; Feb 25 '08, 11:32 PM. Reason: Added code tags. Please use code tags when posting ([code=asp]'some code [/code])

            Comment

            • simonruk1
              New Member
              • Feb 2008
              • 5

              #7
              this is the util.asp page

              [code=asp]
              <%
              Option Explicit
              %>
              <!-- #include file=adovbs.inc -->
              <%
              Const ACTION_VALIDATE = "v"
              Const MODE_ADD = "a"
              Const MODE_MODIFY = "m"
              Const MODE_POST = "p"
              Const MODE_REPLY = "r"

              Function OpenDB()
              Dim dcnDB
              Dim strDatabaseLoca tion ' As String
              Dim rsForMem ' As ADODB.Recordset
              Dim strSQL ' As String
              On Error Resume Next

              strDatabaseLoca tion = Server.MapPath( "../../data/file.mdb")

              Set dcnDB = Server.CreateOb ject("ADODB.Con nection")

              dcnDB.Connectio nString = "Provider=Micro soft.Jet.OLEDB. 4.0;" & "Persist Security Info=False;Data Source=" & strDatabaseLoca tion

              dcnDB.Open

              Set OpenDB = dcnDB

              End Function

              Sub CloseDB(dcnDB)

              dcnDB.Close

              End Sub



              Sub CheckForLogin()

              If Request.Cookies ("MemberID") = "" Then
              Response.Redire ct "../pages/hpage.html"

              End If

              End Sub
              %>
              <%
              Sub CreateVisitorID (dcnDB)

              Dim rsData
              Dim strSQL

              If Request.Cookies ("VisitorID" ) <> "" Then Exit Sub

              strSQL = "INSERT INTO Visitors " & "(VisitDate , Host) " & "VALUES (" & "#" & Date & " " & Time & "#, " & "'"

              If Request.ServerV ariables("REMOT E_HOST") <> "" Then
              strSQL = strSQL & Request.ServerV ariables("REMOT E_HOST")
              Else
              strSQL = strSQL & Request.ServerV ariables("REMOT E_ADDR")
              End IF

              strSQL = strSQL & "')"

              Application.Loc k
              dcnDB.Execute strSQL
              strSQL = "SELECT Max(VisitorID) FROM Visitors"
              Set rsData = dcnDB.Execute(s trSQL)
              Response.Cookie s("VisitorID" ) = rsData(0)
              Application.Unl ock

              rsData.Close

              End Sub

              Sub RecordSearchInf o(dcnDB, strSearch, strSearch1, strSearch2, strSearch3, searchMemID, lngResultCount)
              On Error Resume Next
              Dim strSQL

              CreateVisitorID dcnDB

              strSQL = "INSERT INTO VisitorSearches " & "(VisitorID , SearchTerms, SearchTerms1, SearchTerms2, SearchTerms3, MemID, SearchResults) VALUES (" & Request.Cookies ("VisitorID" ) & ", '" & Replace(strSear ch, "'", "''") & "' , '" & Replace(strSear ch1, "'", "''") & "', '" & Replace(strSear ch2, "'", "''") & "', '" & Replace(strSear ch3, "'", "''") & "', '" & Replace(searchM emID, "'", "''")& "', " & lngResultCount & ")"
              dcnDB.Execute strSQL

              End Sub
              %>

              <%
              Sub MapRequestInfo (dcnDB, MapType, County)

              Dim strSQL

              CreateVisitorID dcnDB

              strSQL = "INSERT INTO MapRequests " & "(VisitorID , MapType, County) VALUES (" & Request.Cookies ("VisitorID" ) & ", '" & Replace (MapType, "'", "''") & "' , '" & Replace(County, "'", "''") & "'" & ")"

              dcnDB.Execute strSQL

              End Sub

              %>
              [/code]
              Last edited by markrawlingson; Feb 25 '08, 11:30 PM. Reason: Added code tags. Please use code tags when posting ([code=asp]'some code [/code])

              Comment

              • CroCrew
                Recognized Expert Contributor
                • Jan 2008
                • 564

                #8
                ACK!!

                Hello simonruk1,

                Can you please add code tags to your posts when posting code and indent code that is inside of If/Then, loops, subs, functions, and where there should be indentions? Please make more of an effort because your last two posts are too hard to read.

                I would like to help but this is just too much.

                Sorry~

                Comment

                Working...