
Chaging SQL Server database at run-time within a report in VB
Hi there,
I know this may have been asked many times before, but I have not found any
post regarding this particular yet. I have found many talking about Access
database though, but not with SQL Server.
I have CR 8.5. I have created a project, added a CR 8.5 designer to it,
created a report through the "Expert" wizard in VB (providing the SQL Server
DSN that it has to connect with), and tested it to verify the db connection
and data. Ok, so far so good.
But now, since this program has to be distributed on different client sites,
the SQL Server database name will be different from one another.
I need a way to programatically change the database to point to the correct
SQL Server database (ODBC DSN) without having to change the code for every
client site I have distributed the program (this is very important).
The code looks like this (very simple):
Dim Report As New CrystalReport1
Private Sub Form_Load()
Screen.MousePointer = vbHourglass
CRViewer1.ReportSource = Report
CRViewer1.ViewReport
Screen.MousePointer = vbDefault
End Sub
Please, I know this can be done. I am looking for the straight-forward
solution for this specific scenario, but any suggestion is accepted.
Many Thanks.
--
Carlitos