Print Page | Close Window

change logon info at running time(ms access)

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Data Connectivity
Forum Discription: How to connect to data sources and export reports
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=254
Printed Date: 29 Apr 2024 at 2:57am


Topic: change logon info at running time(ms access)
Posted By: HSoft
Subject: change logon info at running time(ms access)
Date Posted: 27 Feb 2007 at 9:16pm
hi there,
I'd like to ask the solution for my problem.
I made a new project using ms access 2003,crystal report 9, and visual studio 2005.

I just made a simple access dbase with 1 table(Table 1) and protected with password, o I forgot this table has 2 field(id and desc).
After that I made simple report that using DAO connectivity(save data with report option is disabled).

At last I made simple program(windows app) using visual studio 2005.
I put the CrystalReportViewer component, and these is the code :


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace prj
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void crystalReportViewer1_Load(object sender, EventArgs e)
        {
           
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            crystalReportViewer1.ReportSource = System.Environment.CurrentDirectory + "\\Report1.rpt";
            crystalReportViewer1.LogOnInfo[0].ConnectionInfo.UserID = "Admin";
            crystalReportViewer1.LogOnInfo[0].ConnectionInfo.Password = "12";
            crystalReportViewer1.LogOnInfo[0].ConnectionInfo.DatabaseName = System.Environment.CurrentDirectory + "\\db.mdb";
            crystalReportViewer1.LogOnInfo[0].ConnectionInfo.ServerName = System.Environment.CurrentDirectory + "\\db.mdb";
        }
    }
}


and the problem is  when I move the access database file to other location, the viewer shows a box to be confirmed by my UserID and password,
my question is how must I write in the program so that the box doesnt come out.

thanks



Replies:
Posted By: BrianBischof
Date Posted: 27 Feb 2007 at 11:15pm
I haven't had a chance to do this in VS 2005 yet, but I do know that for MS Access you need to leave the .DatabaseName property blank. That property is only used for SQL Server databases.

-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>


Posted By: HSoft
Date Posted: 27 Feb 2007 at 11:43pm
thanks brian,

I left the .DatabaseName property blank, but that isnt the solution cause the problem still there,
but maybe you could try in 2003 as well (maybe it's the same for this problem)

thanks, any other opinion




Posted By: HSoft
Date Posted: 27 Feb 2007 at 11:58pm
this is the error


http://img137.imageshack.us/my.php?image=error2ry0.png"> http://img137.imageshack.us/my.php?image=error2ry0.png">



Print Page | Close Window