cancel
Showing results for 
Search instead for 
Did you mean: 

Changing to DSN-less ODBC Connection at Runtime

Former Member
0 Kudos


Using VS2012 with SAP CRYSTAL REPORTS, DEVELOPER VERSION FOR MICROSOFT VISUAL STUDIO 13.0.7 in a VB.NET 4.0 Winforms application that I inherited.

The reports currently are using an ODBC DSN connection to SQL Server 2012. I would like to change to a DSN-less connection at runtime. There are too many reports to change at design time.

I have found a couple of examples of changing the connection at runtime, but they all use ADO and set DbConnectionAttributes. I can't seem to find any documentation on DbConnectionAttributes.

Could someone please point me to documentation and/or a good example of changing to DSN-less connection at runtime.

Accepted Solutions (1)

Accepted Solutions (1)

former_member188030
Active Contributor
0 Kudos
Former Member
0 Kudos

Thank you. I will check it all out.

Former Member
0 Kudos

Finally got it figured out.

One must first manually change the connection in a report.

Then use the utility referenced by Bhushan to generate the code for changing connections.

Then modify that code to make it more generic for use at runtime, passing the report file, connection parameters, etc.

The generated code changes the connection info for the specific table(s) in the report that it was run on.

That portion needs to be changed to loop through all of the tables in a report and reset each.

This project does not contain any subreports, so did not need to handle that aspect.

Answers (1)

Answers (1)

Former Member
0 Kudos

Thanks for the info. It seems to be pointing in the right direction, however, I am still at somewhat of a loss.

I can understand that I would need to use the replaceconnection method, however, I still don't see any documentation as to what the correct attributes are.

The utility, seems to generate connection info that matches that in the specified report and what I need is to be able to change to a different connection.

The other samples don't seem to be for ODBC DSN-Less connection.

I would think that changing connection info should be relatively simple.

Isn't there any documentation?