Announcement

Collapse
No announcement yet.

Custom ASP page from hstv.mdb

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Custom ASP page from hstv.mdb

    I am trying to connect to the access database but getting error.
    Microsoft JET Database Engine error '80004005'
    Could not use ''; file already in use.


    PHP Code:
    Set Conn CreateObject("ADODB.Connection")
    set rs=CreateObject("ADODB.recordset")
    Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\program files\homeseer pro\data\hstv\hstv.mdb;User Id=admin;Password=;" 
    Any workaround?
    Thanks
    Please excuse any spelling and grammatical errors I may make.
    --
    Tasker Plugin / Speech Droid
    Tonlof | Sweden

    #2
    Sorry,
    I'm not sure how to get around that.

    I know just enough about VB and Access to connect to the database. In the past I had tried some things to disconnect from the database so I could run the compact function. Then reconnect. I never could figure out how to get that to work. So I don't know how to have it disconnect to allow you to use it.
    --
    Jeff Farmer
    HS 3, HSPhone
    My HS3 Plugins: CFHSExtras, Random, Restart, Tracker, WeatherXML, PanaBluRay
    Other Plugins In Use: APCUPSD, BLOnkyo, Device History, EasyTrigger, HSTouch Server, PHLocation2, Pushover, RFXCom, UltraGCIR3, UltraMon3, UltraPioneerAVR3, X10, Z-Wave

    Hardware: GoControl Irrigation Controler, Schlage Lever Lock, Schlage Deadbolt, Way2Call Hi-Phone, RFXCom RFXrec433 Receiver, WGL 800, TI-103, Z-Net, Pioneer 1120, Pioneer 1021, Pioneer LX302, Panasonic BDT-110, Panasonic BDT-210 x2

    Comment


      #3
      do all the open/recordset (rs) tasks, and at the end before exiting the script do this:

      set rs = nothing
      Conn.Close
      Set Conn = nothing

      There is some error checking to do to keep it from crashing and leaking memory like (adStateClose = 1), (adStateClosed = 0), (adStateOpen = 1)

      If rs.State = adStateOpen Then
      rs.Close
      End If
      Set rs = Nothing

      If (Conn.State <> adStateClosed) Then
      Conn.Close
      End If

      Also, anytime you access a connection, you need to verify the connection worked using "on error goto 0... " and "on error resume next" around the code, same for recordset getting.

      It takes some extra code, but it does better bullet-proof it and reduce crashing and associated memory leaks.

      I've written several web apps over the years that use this type of approach. After adding those little tidbits of error checking and such, I stopped seeing crashes.

      Hope this is helpful. You can try to close it without checking, but you'll generate errors in your script if it's not open or connected.

      It's nice to put something in the log or on the screen to help indicate the problem too.
      huggy_d1

      Automating made easy

      Comment


        #4
        I have the following in the <Serializable()> Public Class HSPI section

        Dim objHSTVDSN As Recordset
        Dim objHSTVActionDSN As Connection


        I then use a function to run the query. I open the connection and then run the query. I close the connection after the query has run.

        Private Function RunSelectQuery(ByVal strSQL As String) As Array
        Dim arrRunQuery As Array = Nothing
        Try
        If sDebugLevel > 1 Then
        hs.WriteLog(IFACE_NAME, strSQL)
        End If
        objHSTVDSN.Open(strSQL, dbname)
        If objHSTVDSN.BOF And objHSTVDSN.EOF Then
        arrRunQuery = Nothing
        Else
        arrRunQuery = objHSTVDSN.GetRows
        End If
        objHSTVDSN.Close()
        Catch ex As Exception
        hs.WriteLog(IFACE_NAME, "Error Query: " & strSQL)
        hs.WriteLog(IFACE_NAME, "Error Select Query: " & ex.Message)
        objHSTVDSN.Close()
        End Try
        Return arrRunQuery
        End Function


        I suppose I could make this function public that way from a web page, it would be possible to return a resultset.

        I had tried to write a function that set the objHSTVDSN and objHSTVActionDSN to nothing. And then to run the compact command for access but it seems to not release the db as long as the hstv plugin is running.
        --
        Jeff Farmer
        HS 3, HSPhone
        My HS3 Plugins: CFHSExtras, Random, Restart, Tracker, WeatherXML, PanaBluRay
        Other Plugins In Use: APCUPSD, BLOnkyo, Device History, EasyTrigger, HSTouch Server, PHLocation2, Pushover, RFXCom, UltraGCIR3, UltraMon3, UltraPioneerAVR3, X10, Z-Wave

        Hardware: GoControl Irrigation Controler, Schlage Lever Lock, Schlage Deadbolt, Way2Call Hi-Phone, RFXCom RFXrec433 Receiver, WGL 800, TI-103, Z-Net, Pioneer 1120, Pioneer 1021, Pioneer LX302, Panasonic BDT-110, Panasonic BDT-210 x2

        Comment

        Working...
        X