Crystal report change database location programmatically. (1 Viewer)

RazorT4x

New member
Local time
Today, 06:57
Joined
Jul 13, 2012
Messages
1
I have this crystal report (CR version 9) and I want to change its database location programmatically. I am doing something right now, but there is a problem. Perhaps my code would explain better.

Code:
    private void MainReport_Load(object sender, EventArgs e)
    {
        var constr = string.Empty;
        constr = Application.StartupPath;
        if (Generate.bForProjects)
            constr = Path.Combine(constr, @"Reports\Projects.rpt");
        else
            constr = Path.Combine(constr, @"Reports\Other.rpt");

        var myConInfo = new CrystalDecisions.Shared.TableLogOnInfo();
        reportDocument1.Load(constr);
        myConInfo.ConnectionInfo.DatabaseName = "ProjectData.mdb";
        myConInfo.ConnectionInfo.ServerName = Application.StartupPath + @"\Data\ProjectData.mdb";
        myConInfo.ConnectionInfo.Password = "";
        myConInfo.ConnectionInfo.UserID = "";
        reportDocument1.Database.Tables[0].ApplyLogOnInfo(myConInfo);

        reportDocument1.Refresh();

        crystalReportViewer1.ReportSource = reportDocument1;
        crystalReportViewer1.Width = this.Width - 50;
        crystalReportViewer1.Height = this.Height - 100;
    }
Now, the problem is, when the form loads this screen pops up

h t t p : // i.stack.imgur . com/FouXC.png
(they won't let me post a link or image, just remove the spaces and you are good to go!)


So, my question is Why the hel* is it coming up? And, when this comes up, I don't enter anything! That's right! I just click finish and it loads the report perfectly! So, if it doesn't needs anything, why the hel* is it asking me for a login?

Also, is this a wrong way to do it, is that's why this window comes up? Is there another way? Anyways, the most important question is how can I get rid of that login window? Its of no use because I don't enter anything? So how?
 

Users who are viewing this thread

Top Bottom