Skip to Content
0
Former Member
Jul 14, 2008 at 10:41 AM

Need help closing OLEDB provider connection to mdb

28 Views

I use CR 11 Release 2 with VB.Net 2005 and an access mdb OLEDB provider. All of my reports were created in CR and then added to my VB.net app. I used a connection to a copy of the db and then changed the source when I loaded a form with the CR Viewer in it:

Dim rpt As New ClientList

Try

Cursor.Current = Cursors.WaitCursor

rpt.DataSourceConnections.Item(0). _

SetConnection("", "" & lblSource.Text, False)

'rpt.DataSourceConnections.Item(0).SetLogon("admin", "admin")

cr1.ReportSource = rpt 'assign the report to the crystal reportt viewer

Cursor.Current = Cursors.Default

Catch exp As CrystalDecisions.ReportSource.EnterpriseLogonException

Cursor.Current = Cursors.Default

MsgBox(exp.Message)

End Try

End Sub

Now I am in a catch 22. I can not close the connection to my db until my app closes. This is bad because a user may wish to delete the project they are working on later on in the session.

The reason I can not close using rpt.close is because it will revert the source back to the db I used at when creating the report originally. So my question is how do I fix this?

Can I make this report lose its connection but keep the data within the report? Or is there a better way? I have 20 reports in my app that are like this.

Thanks

TMA