cancel
Showing results for 
Search instead for 
Did you mean: 

VB6 app getting Database Vendor Code: 17 - failed to open connection

Former Member
0 Kudos

Hello,

I am trying to run an application that generates a report which was written in VB6. The report was written in Crystal Reports 11.0. It worked well on the old server.

We got a new server. Loaded SQL Server 2005. The boss had to buy Crystal Reports 11.5. We have tried to run the report, but it is failing. I can open the report in the Designer. We are using "sa" in the connection string.

The report is built on a stored procedure. I logged into SQL Server with the sa account and was able to run the stored procedure. I've checked to make sure the path is valid. The credentials are being passed by an ini file and that checks out.

I'm not sure what else to look at.

We first open a connection:

Dim sConn As String

sConn = "PROVIDER=MSDASQL;driver={SQL Server};server=" & gstrDBSERVER _

& ";uid=" & gstrUSERID & ";pwd=" & gstrPASSWORD & ";database=" & gstrDBNAME & ";"

Set gobjConnection = New ADODB.Connection

gobjConnection.Open sConn

(doesn't error, so it looks like it is working)

For i = 1 To Report.Database.Tables.Count

Report.Database.Tables(i).SetLogOnInfo _

Chr(34) & gstrDBSERVER & Chr(34), _

Chr(34) & gstrDBNAME & Chr(34), _

Chr(34) & gstrUSERID & Chr(34), _

Chr(34) & gstrPASSWORD & Chr(34)

Next

Then we export the file

With Report.ExportOptions

.PDFExportAllPages = True

.FormatType = crEFTPortableDocFormat

.DiskFileName = strTargetDirectory & "\" & strFilename & "." & "pdf"

.DestinationType = crEDTDiskFile

Report.Export False

end with

I am told this worked with Crystal Reports 11 on the old server. This new server is running Crystal Reports 11.5.

It fails right at the Report.Export line.

Thanks for your help.

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

I think your problem is right here:

SetLogOnInfo

This method was deprecated in CR 9 and while it may have worked for CR XI (the method remains for backward compatibility), the further you move away from CT 8.5 (last version that used the method), the less reliable it becomes. For details see the following:

http://devlibrary.businessobjects.com/BusinessObjectsXIR2/en/en/RDC_SDK/rdc_com_dg_doc/doc/rdcsdk_co...

To resolve the issue, you will have to use the connection properties bag. [This|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/00635998-751e-2b10-9cba-f50ee1e4ef81] article discusses the properties bag in some detail. Also consult the developer's help files:

C:Program FilesBusiness ObjectsCrystal Reports 11.5Helpen dcsdk_com_dg_docdoc dcsdk_com_dg.chm

Now, in a nut shell, this code should work for you:

report.database.tables(1).connectionProperties("data source") = "the server name"

report.database.tables(1).connectionProperties(initial catalog") = "the database"

report.database.tables(1).connectionProperties("user ID") = "the user ID"

report.database.tables(1).connectionProperties("password") = "the password"

As you are using a deprecated method, I suspect this app was created pre version 9 of Crystal Reports and if you run into more DB connection issues, you may have to use the .DeleteAll and .Add methods to run htese reports. But cross that bridge when you get to it...

Ludek

Former Member
0 Kudos

Ludek,

Bingo! That worked.

Thank you. I have been working on this for two days. Once passed that error, I found a few more, but cleared those. Now the app is working fine.

Thanks again!

Answers (0)