cancel
Showing results for 
Search instead for 
Did you mean: 

How to maintain connection to MS Access Database when deploying Application

Former Member
0 Kudos

Hi,

My Application uses an MS ACCESS Database that is stored in the Debug Directory.

Whilst on the development machine, the crystal reports behave as required.

When I deploy the application onto a workstation, the application works fine, but crystal reports is still pointing the location as on the development machine.

After copying all the reports to the debug directory, most errors are eliminated however the connection to database is still causing a problem.

I have tried this without success:

                crConnectionInfo.AllowCustomConnection = true;

                string rptPath = Application.StartupPath;

                crConnectionInfo.DatabaseName = rptPath + @"\POSRSI.mdb";

                crConnectionInfo.UserID = "";

                crConnectionInfo.Password = "";

How can I programmatically, change the crystal reports connection path?

Your help is appreciated.

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

That should work....

Try using this:

CrystalDecisions.Shared.TableLogOnInfo tLogonInfo;

try

{

    foreach (CrystalDecisions.CrystalReports.Engine.Table rptTable in rpt.Database.Tables)

    {

        tLogonInfo = rptTable.LogOnInfo;

        tLogonInfo.ConnectionInfo.ServerName = "";

        tLogonInfo.ConnectionInfo.DatabaseName = D:\Atest\199019\YourMDB.mdb

        tLogonInfo.ConnectionInfo.UserID = "";

        tLogonInfo.ConnectionInfo.Password = "";

        tLogonInfo.TableName = rptTable.Name;

        dtStart = DateTime.Now;

        try

        {

            rptTable.ApplyLogOnInfo(tLogonInfo);

        }

        catch (Exception ex)

        {

            MessageBox.Show("ERROR: " + ex.Message);

            //return;

        }

And don't forget to do the same for subreport connection info.

Don

Answers (0)