CrystalReport and ODBC configuration

J

Jason Huang

Hi,

I've created an ODBC connection with SQL Server 2000, for conneting to
MyDatabase.
In the process of building that ODBC connection, I test the connection and
fine with no problem.
However, in my C#.Net project, I add a CrystalReport MyReport to my project,
then I test running MyReport, it will pop out a small box asking me to key
in DataBase, Username and Password again.
What do I need to do to let MyReport running without keying those data?
Thanks for help.


Jason
 
S

Sanjeevakumar Hiremath

You need to apply logon info to the report before showing it. Here I am
getting the logon info from config file.
Check this code for doing the same. Hope its helpful

Database crDataBase;
Tables crTables;
TableLogOnInfo crTableLogOnInfo;
ConnectionInfo reportConnectionInfo = new ConnectionInfo();
reportConnectionInfo.ServerName =
ConfigurationSettings.AppSettings.Get("serverName");
reportConnectionInfo.DatabaseName =
ConfigurationSettings.AppSettings.Get("DatabaseName");
reportConnectionInfo.UserID =
ConfigurationSettings.AppSettings.Get("UserID");
reportConnectionInfo.Password =
ConfigurationSettings.AppSettings.Get("Password");
//Dummyprint is the CR report file.
Dummyprint dummyrep = new Dummyprint();
DataBase crDataBase = dummyrep.Database;
crTables = crDataBase.Tables;
foreach (Table crTable in crTables) {

crTableLogOnInfo = crTable.LogOnInfo;
crTableLogOnInfo.ConnectionInfo = reportConnectionInfo;
crTable.ApplyLogOnInfo(crTableLogOnInfo);

}


Regards,
Sanjeevakumar Hiremath.
Proteans Software Solutions
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top