Skip to Content
avatar image
Former Member

Programmatically change OLE DB properties fails

Hello,

I have a crystal report (written in CR 2013 Pro), and a Visual Studio Pro 2013 console application using the CR for VS dlls to simply export the CR as a PDF.  When I hardcode the console application to provide the report the necessary login credentials, the PDF is successfully produced.  When I attempt to pass a variable credential to the same server that the crystal was originally written to connect to, it works.  It's when I try to change the server name and database that it fails.

Below is based off of adding snippets from other questions.  I remarked them out - again - works fine with using same Servername as what I used in CR designer, but it fails on the .VerifyDatabase() when I edit variable ServerName.

With crConnectionInfo

.ServerName = ServerName

.Password = PWord

.UserID = UserID

.DatabaseName = DbName

End With

With customerReport

If (DebugStatementsOnOutput = 1) Then

     returnValue = 3

End If

.Load(reportPath)

If (DebugStatementsOnOutput = 1) Then

     returnValue = 4

End If

.SetDatabaseLogon(UserID, PWord, ServerName, DbName)

'For Each crTable As Table In .Database.Tables

'    .SetDatabaseLogon(UserID, PWord, ServerName, DbName)

'Next

'For Each subReport As ReportDocument In .Subreports

'    For Each crTable As Table In subReport.Database.Tables

'        .SetDatabaseLogon(UserID, PWord, ServerName, DbName)

'    Next

'Next

If (DebugStatementsOnOutput = 1) Then

     returnValue = 41

End If

.VerifyDatabase()

If (DebugStatementsOnOutput = 1) Then

     returnValue = 5

End If

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Nov 03, 2015 at 03:22 PM

    What type of database are you connecting to?

    -Dell

    Add comment
    10|10000 characters needed characters exceeded

    • Don Williams Dell Stinnett-Christy

      Don't verify, that can cause the report to use the same source as the report uses. Just make sure all DB tables are exactly the same.

      Use TestConnectivety() if you want to check if its connected or not.

      And use the corresponding MS SQL Native Provider provided by MS for each DB Server.

      Don

  • avatar image
    Former Member
    Nov 04, 2015 at 05:46 PM

    Thanks for the help - With your help, I've got it working now - The code I was using had some things out of order (it seems), plus the help above.  Don - I incorporated your suggestion (just in case) - thanks!

    Working code with some of the parameter stuff removed... 

    Thanks again!

    Bill


    Add comment
    10|10000 characters needed characters exceeded