dede11
asked on
c# : database login window popup with crystal report....
Hi, there,
I'm getting a problem when generating crystal report in .net. specially in c#
There is always a popup window called " Database login", asking input for ServerName, Database, LoginId and password. And whatever login id and password
I'm using an Access database as datasource without any login restrictions...
I created the Crystal Report using ADO.NET DataSet (.xsd file) as Database...
look at my steps and Is there anything I'm missing here? Please help.
~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~
To create a dataset object from a database
Create a new schema file in the project:
1. In the Solution Explorer, right-click the project name, point to Add, and click Add New Item.
2. In the Categories area of the Add New Item dialog box, expand the folder and select Data.
3. In the Templates area, select Dataset.
4. Accept the default name Dataset1.xsd.
This creates a new schema file (Dataset1.xsd) that will be used to generate a strongly-typed dataset. The schema file will be displayed in the ADO.NET Dataset Designer.
Specify where the database is located:
1. In the Server Explorer, right-click Data Connections and select Add Connection.
2. In the Data Link Properties dialog box, click the Provider tab and select a provider
3. Click the Connection tab and specify the location of your database. Click OK.
my database, its tables, and its fields now appear in the Server Explorer under the Data Connections node.
In the Solution Explorer, double-click Dataset1.xsd, Dataset1.xsd should now be displayed in the Dataset tab.
drag the desired tables from the Server Explorer to the Dataset tab of Dataset1.xsd.
Click Save Dataset1.xsd to save the Dataset1.xsd file.
On the Build menu, click Build to generate the dataset object for the project.
In crystal report
To connect a report to an ADO.NET dataset object
1. In the Database Expert, expand the Project Data folder.
2. Expand the ADO.NET Datasets folder.
3. Select the dataset object.
the code is :
private void Form1_Load(object sender, System.EventArgs e)
{
CrystalReport1 cr = new CrystalReport1();
this.crystalReportViewer1. ReportSour ce = cr;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~
this is exactly what i did ....
what is problem ...................?
NOTE : In the Database Expert when i select Database Files as data source the problem doesn't occur ..
dede11
I'm getting a problem when generating crystal report in .net. specially in c#
There is always a popup window called " Database login", asking input for ServerName, Database, LoginId and password. And whatever login id and password
I'm using an Access database as datasource without any login restrictions...
I created the Crystal Report using ADO.NET DataSet (.xsd file) as Database...
look at my steps and Is there anything I'm missing here? Please help.
~~~~~~~~~~~~~~~~~~~~~~~~~~
To create a dataset object from a database
Create a new schema file in the project:
1. In the Solution Explorer, right-click the project name, point to Add, and click Add New Item.
2. In the Categories area of the Add New Item dialog box, expand the folder and select Data.
3. In the Templates area, select Dataset.
4. Accept the default name Dataset1.xsd.
This creates a new schema file (Dataset1.xsd) that will be used to generate a strongly-typed dataset. The schema file will be displayed in the ADO.NET Dataset Designer.
Specify where the database is located:
1. In the Server Explorer, right-click Data Connections and select Add Connection.
2. In the Data Link Properties dialog box, click the Provider tab and select a provider
3. Click the Connection tab and specify the location of your database. Click OK.
my database, its tables, and its fields now appear in the Server Explorer under the Data Connections node.
In the Solution Explorer, double-click Dataset1.xsd, Dataset1.xsd should now be displayed in the Dataset tab.
drag the desired tables from the Server Explorer to the Dataset tab of Dataset1.xsd.
Click Save Dataset1.xsd to save the Dataset1.xsd file.
On the Build menu, click Build to generate the dataset object for the project.
In crystal report
To connect a report to an ADO.NET dataset object
1. In the Database Expert, expand the Project Data folder.
2. Expand the ADO.NET Datasets folder.
3. Select the dataset object.
the code is :
private void Form1_Load(object sender, System.EventArgs e)
{
CrystalReport1 cr = new CrystalReport1();
this.crystalReportViewer1.
}
~~~~~~~~~~~~~~~~~~~~~~~~~~
this is exactly what i did ....
what is problem ...................?
NOTE : In the Database Expert when i select Database Files as data source the problem doesn't occur ..
dede11
I think you need to pass some connection info to CR, below is a link to an example on how to setup access connection.
http://support.businessobjects.com/library/kbase/articles/c2014128.asp
in your case, it should be:
crConnectionInfo = new ConnectionInfo
CrystalReport1 cr = new CrystalReport1();
With crConnectionInfo
'Use the ServerName Property if the report
'connects through OLEDB
.ServerName = "C:\Databases\xtreme.mdb"
'Use the DatabaseName Property if the
'report connects through ODBC
.DatabaseName = "C:\Databases\xtreme.mdb"
End With
crTables = cr.Database.Tables
For Each crTable In crTables
crTableLogOnInfo = crTable.LogOnInfo
crTableLogOnInfo.Connectio nInfo =
crConnectionInfo
crTable.ApplyLogOnInfo(crT ableLogOnI nfo)
Next
CrystalReportViewer1.Repor tSource = cr
dylan
http://support.businessobjects.com/library/kbase/articles/c2014128.asp
in your case, it should be:
crConnectionInfo = new ConnectionInfo
CrystalReport1 cr = new CrystalReport1();
With crConnectionInfo
'Use the ServerName Property if the report
'connects through OLEDB
.ServerName = "C:\Databases\xtreme.mdb"
'Use the DatabaseName Property if the
'report connects through ODBC
.DatabaseName = "C:\Databases\xtreme.mdb"
End With
crTables = cr.Database.Tables
For Each crTable In crTables
crTableLogOnInfo = crTable.LogOnInfo
crTableLogOnInfo.Connectio
crConnectionInfo
crTable.ApplyLogOnInfo(crT
Next
CrystalReportViewer1.Repor
dylan
ASKER
thanks for response
i am using MS access 2003...
dylanyee
the code missing directive or assemply the compiler generated the following message:
( The type or namespace name 'Database' could not be found (are you missing a using directive or an assembly reference?)
dede11
Is your CrystalReport1 a class that auto-generated by C# when you added report to your project? If so you should be able to use Database.Tables method because all auto-generated report class is overriding CrystalDecisions.CrystalRe ports.Engi ne.ReportC lass
dylan
dylan
ASKER
mmm ...yes ..
i solved the problem with the following code :
private void Form1_Load(object sender, System.EventArgs e)
{
string connString = @"Provider=Microsoft.Jet.O
OleDbConnection conn = new OleDbConnection(connString
conn.Open();
string query = "SELECT * FROM Table1";
OleDbDataAdapter oleDA = new OleDbDataAdapter(query,con
DataSet1 dataReport = new DataSet1();
oleDA.Fill(dataReport,"myP
CrystalReport1 cr = new CrystalReport1();
cr.SetDataSource(dataRepor
crystalReportViewer1.Repor
}
it is worked ....
thanks for ur response
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
mlmcc