473,386 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Problem connecting to database using crystal report

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
7 4383
Shashi Sadasivan
1,435 Expert 1GB
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
251 100+
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
Here is an amazing link for your problem.
Thank you for the link, it is very useful.
Mar 27 '08 #4
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
1,435 Expert 1GB
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
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
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

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

Similar topics

1
by: jane | last post by:
I use following code to create a Crystal Report by connecting to an access db in ASP. It works fine. Now I switch to SQL Server and it doesn't work. It seems to me there is nowhere I can add login...
0
by: Max | last post by:
Hi wise people, Has anyone encountered the Crystal Reports problem I describe below? If so, how did you solve it? It seems that every article posted on google regarding CR and logon problems is...
0
by: Plunaldo | last post by:
Hi All I use a ODBC Connection to Connect to a AS400 System. I created a new DSN in the Windows System. The Databaseaccess is made directly out of the Crystal Report...so the Crystal Report is...
3
by: Milan Todorovic | last post by:
Hello, I need help. I have experience in ASP.NET programming, but this is my first dealing with Crystal Reports. I'm trying to make the most basic report purely for testing purposes: connect to...
1
by: hlam | last post by:
After deploying the application and running it on an XP p.c. I get the message from Crystal Reports Viewer Window: Load Report Failed Here is what I've used: . Connecting to Sql Server 2000...
3
by: route_coder | last post by:
I am using access database to create a crystal report in VB.NET Everything works fine when I run on my machine. But when I am deploying it other windows machines. It is asking for database server...
1
by: cantonarv | last post by:
Just trying to do a basic crystal report and viewing it with dynamic sql server database but dont no what i'm doing wrong? I am using integrated security. Dim myRpt As crpt1 = New crpt1 ...
1
by: sushanta | last post by:
Dear sir, In details my problem is: What I want to do: Populate data from database in the crystal report with a specific query What I have done: I have decleared a dataset YWStatus.xsd ...
1
by: Priyam Ganguly | last post by:
Hello everyone, I hav been facing a problem since a few days. I'm using crystal report with .net 2005 (.Net framework 2.0). In a report I'm retrieving the values from a database table and showing...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.