+ Reply to Thread
Results 1 to 4 of 4

Pivotcache database stays locked

  1. #1
    Registered User
    Join Date
    04-12-2006
    Posts
    25

    Pivotcache database stays locked

    Hi,

    A question; I've created a pivottable and cache based on a access query in code, in stead of using the pivottable wizard. then I wrote some code to update the tables (charts). Purpose is to create a very transportable db and worksheets, now I only have to alter one connectionstring.
    But, here's the problem, when I update the pivottables, the database stays locked. After opening all the other recordsets, the db unlocks, but using this code it stays locked

    If someone can help me out, thanks

    in class:
    Dim RS As New ADODB.Recordset
    Public StrCN As String

    Public Sub PvtCacheUpdate(ByRef WsCodeName As Worksheet, ByRef PvtTableName As String, _
    ByRef ConnString As String, ByRef StoredProcedure As String)
    Dim PC As PivotCache
    Dim PT As PivotTable
    On Error GoTo catch
    Set RS = New ADODB.Recordset
    Set PT = WsCodeName.PivotTables(PvtTableName)
    Set PC = PT.PivotCache
    PC.MaintainConnection = False
    StrCN = ConnString

    Call RS.Open("[" & StoredProcedure & "]", StrCN, adOpenForwardOnly, adLockReadOnly, adCmdTable)
    Set PC.Recordset = RS
    PT.RefreshTable
    catch:
    If RS.State = ObjectStateEnum.adStateOpen Then RS.Close
    Set RS = Nothing
    Set PC = Nothing
    Set PT = Nothing
    End Sub

  2. #2
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by Mikeyhend
    Hi,

    A question; I've created a pivottable and cache based on a access query in code, in stead of using the pivottable wizard. then I wrote some code to update the tables (charts). Purpose is to create a very transportable db and worksheets, now I only have to alter one connectionstring.
    But, here's the problem, when I update the pivottables, the database stays locked. After opening all the other recordsets, the db unlocks, but using this code it stays locked

    If someone can help me out, thanks

    in class:
    Dim RS As New ADODB.Recordset
    Public StrCN As String

    Public Sub PvtCacheUpdate(ByRef WsCodeName As Worksheet, ByRef PvtTableName As String, _
    ByRef ConnString As String, ByRef StoredProcedure As String)
    Dim PC As PivotCache
    Dim PT As PivotTable
    On Error GoTo catch
    Set RS = New ADODB.Recordset
    Set PT = WsCodeName.PivotTables(PvtTableName)
    Set PC = PT.PivotCache
    PC.MaintainConnection = False
    StrCN = ConnString

    Call RS.Open("[" & StoredProcedure & "]", StrCN, adOpenForwardOnly, adLockReadOnly, adCmdTable)
    Set PC.Recordset = RS
    PT.RefreshTable
    catch:
    If RS.State = ObjectStateEnum.adStateOpen Then RS.Close
    Set RS = Nothing
    Set PC = Nothing
    Set PT = Nothing
    End Sub
    Hi,

    All Dutch to me, (doubly so?) - but does the adLockReadOnly get to the LockType:= place, ie, are your parameters correctly sequenced or could StrCN (ex ConnString) contain spaces or a comma?

    (just fishing)
    ---
    Si fractum non sit, noli id reficere.

  3. #3
    Registered User
    Join Date
    04-12-2006
    Posts
    25
    Hi Bryan,

    No, doing nothing wrong I'm aware off.

    Used the same 'Call RS.open()' to populate 7 comboboxes in a form, from the same db, all queries, and here it closes again.
    The connectionstring works for the other connections


    Mike

  4. #4
    Registered User
    Join Date
    04-12-2006
    Posts
    25
    Is there a way to unlock the database in code from excel?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1