BusinessObjects Board

How can I rename the DataProviders???

I have some reports in a directory and I have to rename the DataProviders of its reports.
How can I do it???
I put this code to prove but if I put the sentences dpMyDataProvider.Load I receive the error “Error loading the DataProvider” and if I doesn’t put it, I not received error but the DataProviders Names of the reports aren’t modified!!!

What happens? How can I rename the DataProviders???

Dim ArrayNames(5)

ArrayNames = Array("A", "B", "C", "D", "E", "F")


Do While strCurrentFile <> ""
  
  
  If strCurrentFile <> ThisDocument.Name &amp; ".rep" Then

  Set docMyDocument = Application.Documents.Open(strDocPath &amp; strCurrentFile)
    
    If docMyDocument.Name <> "" Then
    
        For j = 1 To docMyDocument.DataProviders.Count
            
            
            Set dpMyDataProvider = ThisDocument.DataProviders(1)
            
            'dpMyDataProvider.Load
            
            dpMyDataProvider.Name = ArrayNames(j - 1)
            
            'dpMyDataProvider.Unload

            Application.Interactive = False
            dpMyDataProvider.Refresh
            Application.Interactive = True
            
        
        Next j  ' Next data provider, if any more
        
    End If
    
    docMyDocument.Save
    docMyDocument.Close
    
  End If
    
  ' Get next document, if there is one.
  strCurrentFile = Dir

Loop


mg (BOB member since 2004-01-07)

This code works to change the first data provider name:

Sub main()

    Dim boDoc As busobj.Document
    Dim boDP As busobj.DataProvider
    
    Set boDoc = ThisDocument
    Set boDP = ThisDocument.DataProviders.Item(1)
    boDP.Name = "Test"
    Set boDP = Nothing
    Set boDoc = Nothing
    
End Sub

You do not have to “load” the data provider to rename it. This code was run in version 5.1 and after it was completed the first (and in this case only) data provider was named “Test”.

So while I don’t know exactly what is wrong with your code, it looks very similar and would seem that it should work.


Dave Rathbun :us: (BOB member since 2002-06-06)

I seem to remember that if you change any of the properties that are “manually” done in data manager (like name), it will fail if “loaded” first. In this utility, I set those properties “before” loading the data provider, for this very reason.

I also seem to remember that if the data provider is not marked refreshable, it will also “fail” when you try to load it. Yes, I meant refreshable, not editable (though that would likely cause the same error).


Dwayne Hoffpauir :us: (BOB member since 2002-09-19)