Data Connectivity
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Data Connectivity
Message Icon Topic: change database location for a report programmatic Post Reply Post New Topic
Author Message
RazorT4x
Newbie
Newbie
Avatar

Joined: 13 Jul 2012
Location: India
Online Status: Offline
Posts: 1
Quote RazorT4x Replybullet Topic: change database location for a report programmatic
    Posted: 13 Jul 2012 at 5:52am
Hi all, Good day to every one! This is my first post here!
So, 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.


  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

http://i.stack.imgur.com/FouXC.png

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?
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.