By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
463,190 Members | 626 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 463,190 IT Pros & Developers. It's quick & easy.

Problem connecting to database using crystal report

P: 19
Hi all,
Can anyone help me on how to create crystal reports in a .net windows application?

The problem is, i have an OleDbConnection object named 'conn' which I create dynamically to connect to an access database and i want to use this connection to create crystal reports.

I would welcome any help or alternative.

Thank you all in advance.
Mar 25 '08 #1
Share this Question
Share on Google+
7 Replies

Shashi Sadasivan
Expert 100+
P: 1,435
A crystal report consists information of tables in a database. Each table can be attached to a different database, and hence you should set the database connection of each individual table

CrystalDecisions.CrystalReports.Engine.Table

The table property has a TableLogOnInfo Property which then has a connectionInfo property. Set this connection info property

CrystalDecisions.Shared.ConnectionInfo

you would need to set the datasource, database name, userid password if apllicable, etc
Mar 26 '08 #2

nev
100+
P: 251
nev
Hi all,
Can anyone help me on how to create crystal reports in a .net windows application?

The problem is, i have an OleDbConnection object named 'conn' which I create dynamically to connect to an access database and i want to use this connection to create crystal reports.

I would welcome any help or alternative.

Thank you all in advance.
Here is an amazing link for your problem.
Mar 26 '08 #3

P: 19
Here is an amazing link for your problem.
Thank you for the link, it is very useful.
Mar 27 '08 #4

P: 19
A crystal report consists information of tables in a database. Each table can be attached to a different database, and hence you should set the database connection of each individual table

CrystalDecisions.CrystalReports.Engine.Table

The table property has a TableLogOnInfo Property which then has a connectionInfo property. Set this connection info property

CrystalDecisions.Shared.ConnectionInfo

you would need to set the datasource, database name, userid password if apllicable, etc
Thank you for the help. I tried using the idea to connect but I am not yet success. Please tell me what is wrong with this code bcus it fails to connect and I am prompted to provide the connection credentials.

/*
Note: I am using a passworded access database
(1) The code below fails to connect to the tables in the database and I don't know why.
(2) The second problem is the user id, what if someone logs in as a user other than Administrator?
*/

private void daily_report_frm_Load(object sender, System.EventArgs e)
{
//report object
date_report drpt=new date_report();
//inits
TableLogOnInfo logOnInfo = new TableLogOnInfo ();
int i = 0;

// Loop through every table in the report.
for (i=0;i == drpt.Database.Tables.Count - 1;i++)
{
// Set the connection information for the current table.
logOnInfo.ConnectionInfo.ServerName = "";
logOnInfo.ConnectionInfo.DatabaseName = "";
logOnInfo.ConnectionInfo.UserID = "Admin";
logOnInfo.ConnectionInfo.Password = "db_password";
drpt.Database.Tables [i].ApplyLogOnInfo (logOnInfo);
//test connectivity
MessageBox.Show(drpt.Database.Tables[i].TestConnectivity().ToString());
}



//report view
this.daily_report_viewer.ReportSource=drpt;
}
Mar 27 '08 #5

Shashi Sadasivan
Expert 100+
P: 1,435
You have not specified which server and databse to connect to.
Have a look at your connection string that you use. The serverName is the datasource, and the databaseName is the initial catalog.

Without these the crystal repost dose not know where to connect to.

Thank you for the help. I tried using the idea to connect but I am not yet success. Please tell me what is wrong with this code bcus it fails to connect and I am prompted to provide the connection credentials.

/*
Note: I am using a passworded access database
(1) The code below fails to connect to the tables in the database and I don't know why.
(2) The second problem is the user id, what if someone logs in as a user other than Administrator?
*/

private void daily_report_frm_Load(object sender, System.EventArgs e)
{
//report object
date_report drpt=new date_report();
//inits
TableLogOnInfo logOnInfo = new TableLogOnInfo ();
int i = 0;

// Loop through every table in the report.
for (i=0;i == drpt.Database.Tables.Count - 1;i++)
{
// Set the connection information for the current table.
logOnInfo.ConnectionInfo.ServerName = "";
logOnInfo.ConnectionInfo.DatabaseName = "";
logOnInfo.ConnectionInfo.UserID = "Admin";
logOnInfo.ConnectionInfo.Password = "db_password";
drpt.Database.Tables [i].ApplyLogOnInfo (logOnInfo);
//test connectivity
MessageBox.Show(drpt.Database.Tables[i].TestConnectivity().ToString());
}



//report view
this.daily_report_viewer.ReportSource=drpt;
}
Mar 27 '08 #6

P: 19
The code I submitted works fine when connecting to ms sql server without the serverName and databaseName and even without user id on my system. But the problem is that I tried what you suggested and did not work because may be I am connecting an access database and not sql server. The second possibility may be how I connected to the database using crystal report.
If I connect using ODBC would I need to create the DSN on the deployment machine?

I have tried several times connecting my access database using this form with the fields below could anyone tell me exactly what they want?

Database Name: .....................
Database Type:....Access
User ID:....Admin
Password: ...............
Jet System Database: .........
Jet Database Password: ................


You have not specified which server and databse to connect to.
Have a look at your connection string that you use. The serverName is the datasource, and the databaseName is the initial catalog.

Without these the crystal repost dose not know where to connect to.
Mar 28 '08 #7

P: 19
Thank you all.
I finally was enable to connect to my access database through crystal report.
The database name: is the path to the database file
User ID: not neccessary
Password: not neccessary
Jet System database: C:\Documents and Settings\Administrator\Application Data\Microsoft\Access\System.mdw
Jet Database password: password of access file

I am now working on trying to display the crystal report in my application (connecting to the tables involved at run time).
Any help would be welcomed.

The code I submitted works fine when connecting to ms sql server without the serverName and databaseName and even without user id on my system. But the problem is that I tried what you suggested and did not work because may be I am connecting an access database and not sql server. The second possibility may be how I connected to the database using crystal report.
If I connect using ODBC would I need to create the DSN on the deployment machine?

I have tried several times connecting my access database using this form with the fields below could anyone tell me exactly what they want?

Database Name: .....................
Database Type:....Access
User ID:....Admin
Password: ...............
Jet System Database: .........
Jet Database Password: ................
Apr 2 '08 #8

Post your reply

Sign in to post your reply or Sign up for a free account.