Troubleshooting Database Login Errors using Crystal Reports with .NET
page 1 of 3
Published: 23 Jul 2004
Unedited - Community Contributed
Abstract
Many of the issues addressed on the forums are about logging onto Crystal Reports. This article shows how to debug some of these issues.
by Eric Landes
Feedback
Average Rating: 
Views (Total / Last 10 Days): 80325/ 95

Introduction

I participate in a few Crystal Reports centric mailing lists and forums.  One common area of issues I see are problems when logging onto a database in an ASP.NET application.  To help with these issues, I thought I would write this article with some troubleshooting techniques for database logon problems.

I assume that you are familiar with ASP.NET, and Crystal Reports (either .Net or 8.5 and greater).  The databases covered will be SQL Server and DataSets. 

 


View Entire Article

User Comments

Title: Load Report Failed   
Name: Chirag Bhandula
Date: 2006-02-17 12:14:48 AM
Comment:
Hi I am using Crystal Reports for visual studio 2005. I Have to make connections thru wizard. And when i upload my report on server then i just receive a browser on which there is a message, Load Report Failed
Title: Re: C# error reading mysql   
Name: Eric Bos
Date: 2006-02-06 3:30:24 AM
Comment:
Syed Aftab Hayat,

Did you base your report on a XSD?
In that case your report should not ask you about login, since there should be no reason to login. :S
Makes sense uh?

If you did, make sure you name your datatable you retrieve has the same name as the table in your XSD.

Hope it works
Title: C# error reading mysql   
Name: Syed Aftab Hayat
Date: 2006-02-04 2:04:26 PM
Comment:
I am trying to use crystal reports to view the MySql db in c# in visual stuido.net 2003.
1. Trying directly connecting through making a dsn an error occurs when the form of report viewer is loaded. It says unable to load row set.

2. Trying through a data set, the report viewer but gives a login denied error when asks for password, db, uid and server name.

ASAP reply would be appreciated. Thank you very much
Title: Logon errors   
Name: Eric Bos
Date: 2006-02-03 7:37:20 AM
Comment:
After some hard suffering and thinking I think I figured it out how to bind a dataset to the report.

I will put some sample code (VB.NET):

'create report object
Dim rpt As New ReportDocument
'load the report
rpt.Load(MyReportLocation)

'create dataset
dim ds as new DataSet
'get your data
dim dt as DataTable = DatabaseClass.GetSomeQuery()
'add your table to the dataset
ds.Tables.Add (dt)

'this is important : table name = name in your XSD
dt.TableName = "MyTable"
'add the dataSET to the report
rpt.SetDataSource(ds)

'if you have subreports
Dim rptdoc As ReportDocument
'get the subreport
'remember, names are case sensitive
rptdoc = rpt.OpenSubreport("mySubReport")

'create new dataset
ds = new DataSet
'get your data
dim dt as DataTable = DatabaseClass.GetSomeDataForSubreport()
'add your table to the dataset
ds.Tables.Add (dt)
'should match the one in the XSD
dt.TableName= "MySubReportName"

'set the datasource on the subreport
rptdoc.SetDataSource(ds)

to make this work do the following to your report:
export a XSD from your dataset
use e.g. ds.WriteXMLSchema(yourXSDFile)

then use the XSD as your datasource for your report.

choose datasource: ADO.NET (XML)
filepath: select your XSDFile
check : use dataset from class
and press finish.

drag/drop your fields from your xsd and you're done.

hope this helps
Title: Hot to call crystal report in asp.net with vb code (I have already report file)   
Name: venkatesh
Date: 2006-01-27 5:14:13 AM
Comment:
Hi ,

I create a web application .In my system I have one report file .

shall i call that report file.

If i call crystal report using query (with in a application i create blank report and select databse and table )this application i got putput fine in vb code

even i copyed(out side report) and paste in my application folder.and then what step can i do?

pls give me code.
my email id :mcanetvenkat@hotmail.com
Title: Null values in crystal report   
Name: sandy
Date: 2006-01-19 11:51:20 PM
Comment:
This article is good. I am facing another problem I am binding a dataset with a view and binding that dataset into crystal report. In that view two fields contain null values also, so when i am binding that fields to the report it is showing blank in the place of null fields. how can i avoid that?
Title: Crystal Reports With Multi Tables   
Name: Babu A
Date: 2006-01-02 9:03:58 AM
Comment:
I Have Created One Report With 2 Tables. I have Passed Connection Info and Filled Data Set, Report Is Appearing as Blank. But Data Existed in the Data Set , Ply Help Me .

Thanks In Advance
Title: how to pass pass query in crytrpt in vb.net   
Name: saritha
Date: 2005-12-29 4:19:51 PM
Comment:
Hi all,
Am saritha am still facing problem with this coz my query contains outerjoin may be due to this am unable to diaply my report so kindly plz try to help me
Title: Crystal Report 9 Logon Error   
Name: Tejas Chonkar
Date: 2005-12-09 7:38:51 AM
Comment:
Hi,
Please help me with this error:

I'm having a report in my ASP.Net application with subreports, I'm using SQL Server authentication in my development environment, and Windows Authentication on live server. I'm actually populating a local dataset with the query results from the database and attaching this dataset as the source of the report document, the same is done for all the subreports, The report works fine in development environment but on live server it fails.
Title: Crystal Report 9 Logon Error   
Name: Tejas Chonkar
Date: 2005-12-09 7:34:50 AM
Comment:
Hi,
Please help me with this error:
Title: Logon Error when binding dataset   
Name: Pip Danby
Date: 2005-11-15 3:43:51 PM
Comment:
My similar problems were completely solved, thanks to CR supports by downloading the latest merge modules from http://support.businessobjects.com/fix/merge_modules.asp#04

As a note: all articles to this subject recommend that the binding object is a DataSet, not DataTables.
Title: Logon Failed error for DataSets in crystal Report   
Name: venkat
Date: 2005-11-07 12:49:40 AM
Comment:
I have problem in sending DataSet to Crystal Report.I have created DataSet and when I'm trying to add DataSet to the crystal report,it it asking for connection information Dialog box.Even if I refresh the connection information ,Object reference not set to an instance of an object error is coming,and I am using DataBase on remote machine.This is problem is for all DataSets and all Crystal Reports in my application.This problem is not found in my other application.Please give me solution.
Thanks in advance
Title: Changing Server Name throu DSN   
Name: Ahmad
Date: 2005-10-12 10:13:22 AM
Comment:
I had no logon problem with that technique but when i changed my database to a new server 'logon problem' retuen back.thanks for your any help
Title: Logon Error When Building a DataSet   
Name: Nauras Jamal
Date: 2005-10-01 4:32:01 AM
Comment:
I was facing the same problem. Even after trying
CrystalReport1.SetDataSource(objDS.Tables[0]) AND
CrystalReport1.SetDataSource(objDS)!!
What i found made it work was:
ReportDocument cReport;
cReport.Database.Tables[0].SetDataSource[ds];
Hope this helps!
Title: Logon Error when Binding DataSet   
Name: Melvin Ramirez
Date: 2005-09-09 5:18:04 PM
Comment:
\
Title: create crystal report for asp.net   
Name: DuongNga
Date: 2005-07-30 2:41:04 AM
Comment:
I have been a file report1.rpt. I wants to view file report1.rpt in application web by asp.net. Please help me
Title: RE: Logon Error Wrok around (By Jonathan)   
Name: Todd Kneib
Date: 2005-06-07 9:55:03 AM
Comment:
I was have the logon error binding my multitable Dataset to my report (which uses both table). Interestingly, this problem started happening when my company got us new developer boxes. On my old box, the report SetDataSource worked, but on the new box it did not. If I copied the compiled assembly (either compiled on the old or new box) to the old box, it worked fine, but on the new box it had logon issues.
This tells me its a runtime issue.
Having said that, the solution Johnathan suggested works on both boxes, so that change is getting checked in and on to production.
There could be a gotcha with the solution though, if the tables in your dataset are somehow not in the same order as in the report, you may need to do more work, but I would expect it to work.

Thanks Jonathan!
Todd
Title: Takes hours to run a crystal report   
Name: rk
Date: 2005-06-06 11:25:41 AM
Comment:
Hi,
I have a crystal report in asp.net(.net version 1.0).It uses a stored procedure that gets data from multiple tables.It takes just 3 seconds to run from query analyser.The same data takes 1 hr to load on the crystal report.So I not able to understand what's going wrong with my case.
Thanks for any help.
rk
Title: code error   
Name: hossni hendy
Date: 2005-06-06 10:32:18 AM
Comment:
(System.InvalidOperationException: The ConnectionString property has not been initialized.)
what the error could be for ?
Title: InitializeComponent   
Name: hossni hendy
Date: 2005-06-06 5:22:29 AM
Comment:
i am creating a form with asp.net using c# language, if it's no code error shown and every thing looks fine but there is no connection with the database.
i think the problem with InitializeComponent so how can i test this or how can i figure that out?
Title: It's very Nice Yaaar.....   
Name: Praveen.K
Date: 2005-06-04 4:48:41 AM
Comment:
Hi,

It's very nice code. I implemented successfully. Thanks for providing this code. And this is basic problem error. Give different processes and methods for developing Crystal Reports and Runtime Parameters.

Bye
Praveen,
Software Developer.
Title: Login ODBC DSN?   
Name: Sandy
Date: 2005-06-02 3:07:33 PM
Comment:
I cannot get the login information to work and am thinking it is because my report was created using a DSN. Does anyone know how to pass the DSN login information from an ASP.Net page to the report?
Title: Logon Error When Binding a DataSet   
Name: James Tyree
Date: 2005-06-01 4:02:14 PM
Comment:
I have found that if you create a report using an ODBC DSN, that you cannot switch gears, so to speak, in your vb.net code and try and specify SQL Server login info (non odbc/dsn).

Is this correct??

James
Title: Logon Error Wrok around   
Name: Jonathan
Date: 2005-05-23 10:40:00 AM
Comment:
Excellent Article... Thanks Jonathan
that error make me sleepless till i found ur article.
assinging setDataSource to individual works fine
i spent for nearly 8 hourse and become semi dead
thanks again.
Title: logon failed using dsn connection   
Name: manisha
Date: 2005-05-04 8:52:46 AM
Comment:
i m trying to make a crystal report using excel sheet & sql database without dsn it was working ,but for dsn i gave uid,pwd,dsn name... everything still when i run the program ,it is showing me logon failed error, please help me!!!!!
Title: crystal reports with stored procedure for oracle   
Name: Kamy
Date: 2005-05-02 5:52:02 PM
Comment:
Eric...what are the steps for creating crystal reports .net using stored procedure for oracle.
Title: Reports with Dataset   
Name: SAM
Date: 2005-05-02 5:02:01 PM
Comment:
How can i create a report by setting the datsource to a dataset.I have a very complex query.so i am thinking not to create a dataset.xsd file.but just create a datset with the query in the code and Bind it to Crystal report.is it possible?if not then when i create a dataset.xsd file..do i need to link the tables in design time.I cannot link it using visual link..since in my query the Joins are complex with expressions.plz help eric.if possible tell me the steps...as such i am familiar with crystal reports and datasets.
Title: RE:Crystal Reports Bind Problem   
Name: Eric Landes
Date: 2005-04-28 10:07:46 PM
Comment:
Have you tried binding to your dataset in design time? Write out your dataset to a file using ds.writexml, then set datasource with that dataset. See if that helps.
Title: Mac   
Name: Crystal report fields
Date: 2005-04-28 4:00:51 PM
Comment:
Hi....
I have a crystal report with some 30 fields.for some fields i need to write a separate query to get the record and show them along with these fields.how can i do?

thanks in advance
Title: Crystal report Bind Problem   
Name: sameer
Date: 2005-04-28 3:50:22 PM
Comment:
Hi I have a crystal report which takes datasource from Multiple tables (7 in my case) which i set during design time.Now when I am writing a similar query with few modifications..and binding the crystal report with dataset..it still takes the query which i created during run time.so even if i change the causes it has no effect on the report.I am using the Following
oRpr.SetDataSource(dsCells)
Thanks
Title: RE: dynamic parameter   
Name: Eric Landes
Date: 2005-04-26 10:02:55 PM
Comment:
If you're talking about classic asp, I'm not sure where you can look. However, if this is an asp.net application, go to http://aspalliance.com/crystal to look at some articles, or check out the community link for some mailing lists that can help also. Since I'm not sure how you're displaying your report, I can't really answer the question here, but check out the mailing lists that have experts also.
Title: dynamic parameter   
Name: sopakiriba Lawson
Date: 2005-04-25 8:35:37 AM
Comment:
When trying to view my crystal report from ASP i get this error message "Error Occurred on server. -2147217394: Missing parameter values". How do i solve this problem? My report has parameters
Title: nightmare - Crystal Report too wide   
Name: Scott
Date: 2005-04-09 6:40:32 AM
Comment:
For some reason when I create reports all the sections have a width of 11518. It's readonly so I can't change it and theres nowhere in the wizard where this is specified.

Its driving me bonkers as my reports appear completely off to the right. I can't find anything in the documentation or on the net, surely other people must be having this problem with Crystal Reports and there must be some simple solution cause without it the whole reporting engine is pretty useless.

Sorry, I know this isn't related but since you seem to be one of the few people on the net who seem to be able to make sense of this product maybe you or one of the other readers might have experienced this and found a work around.

s.
Title: RE: Cached reports   
Name: Eric Landes
Date: 2005-04-07 10:24:38 PM
Comment:
S. I'll look into Cached reports, although that's not currently in the works. Thanks for the complement.
Title: Cached Reports - How do I use them?   
Name: Scott
Date: 2005-04-07 1:49:45 PM
Comment:
Thats what i was going to ask( as well as giving a complement ). I have been trying to use the Cached features of Crystal Reports but without much luck. Do you have any tips or maybe an article on how this works. Im sure is pretty straight forward but I just can't work it.

s.
Title: nice   
Name: Scott
Date: 2005-04-07 1:44:51 PM
Comment:
You sir are a legend.

s.
Title: Problem Resolved   
Name: Marius
Date: 2005-03-22 11:14:27 AM
Comment:
I kind of resolved the problem.

Some say you have to oRpt.SetDataSource(ds), others say oRpt.SetDataSource(ds.Tables[0])...

Well, I say when you have ONLY 1 table in the data set, it expects for a Table, rather than for a DataSet. From TWO tables on, it expects a DataSet.
To be sure and to have a constant design, I introduce another table in the datasource and I ALSO INSERT IT IN THE REPORT, even if I do not use it. I Fill my DataSet with both tables from an SQLCommand, initially setting the XML Schema:
// fill the xmlSchema which should match the DataAdapter's schema
dataSet.ReadXmlSchema(new System.IO.StringReader(strXmlSchema));
//create table mappings
int i = 0;
foreach(System.Data.DataTable dt in dataSet.Tables)
{
dataAdapter.TableMappings.Add((i == 0)?"Table":("Table"+i.ToString()), dt.TableName);
i++;
}
// fill the DataSet using our DataAdapter
dataAdapter.Fill(dataSet, "Table");

strXmlSchema was necessary to set the name of the tables AND the way the data is presented (for example, I encountered a problem when the XSD contained an AutoCompelte attribute to one of the Fields. When NULL values were encountered, the field was autoincremented... resulting into a false report. I deleted from strXmlSchema those attributes and everything went OK)
The TableMappings were necessary because when filling the DataSet, every Table supplied by the Query (sqlCommand execution) is named in order: Table, Table1, Table2 and so on. Without the Mappings, the DataSet would have contained the tables from the XSD, but empty ones, and some Table, Table1, Table2...

Happy Coding to everyone! (Even if you have to use Crystal Reports :D)
Title: RE: Persistent Logon Failed Error   
Name: Eric Landes
Date: 2005-03-10 10:06:08 PM
Comment:
Also try Richard Dudley's excellent followup to this at http://www.aspalliance.com/crystal/redir.aspx?ArticleURL=http://aspalliance.com/532
Title: Persistent Logon Failed Error   
Name: Curt
Date: 2005-03-10 1:09:28 PM
Comment:
I tried what you listed (in C#), but it seems that no matter what I do I still get a logon error. If you know of any other sources of information regarding this problem, I'd greatly appreciate it.
Title: crystal report db login prompt   
Name: Dave
Date: 2005-03-06 10:02:52 AM
Comment:
Excellant article! Was having a huge problem setting up a windows .net program on the client. Every report was prompting for a db login. Assigning the ds directly was causing multiple logins. Setting the datasource to ds.tables(0) resolve this issue. Spent 9 hours working on this issue,
became BRAIN DEAD. Again, Excellant article.

Thank you!
Title: Logon Error Wrok around   
Name: Jonathan
Date: 2005-02-04 1:43:12 PM
Comment:
I still have bad dreams about this problem and the solutions are tough since this error appears for both a lack of proper loging information and permission errors. A work around is to to bind your tables from a dataset at runtime. Using a loop similar to this:

DataSet myDataSet = new DataSet();
myDataAdapter.Fill(myDataSet);

CrReport myReport = new CrReport();
for(int i=0; i < crReport.Database.Tables.Count; i++)
{
myReport.Database.Tables[i].SetDataSource(myDataSet.Tables[i]);
}

CrystalReportViewer1.ReportSource = myReport;

works since all authentication is done when you fill your dataset and not when you load the report. note: this workaround implies that your dataset has a 1 to 1 table mapping with your report. If not things will not display as you would expect. I hope this sets you in right direction...
Title: Can i make Crystal Report Run time   
Name: Pradeep
Date: 2005-01-07 1:37:41 AM
Comment:
In our Product , we are using Multipul Database and i want to know about can i make crystal report on run time in .net like visual basic.

Thanks
Title: Logon Error When Binding to a DataSet   
Name: KL
Date: 2004-10-18 4:39:57 PM
Comment:
I've been having a similar problem which I resolved by emperically deducing the following (No thanks to the myriad of books and help resources that I have.)

If your dataset has only one table, then the ReportDocument.SetDataSource() should be passed a DataTable object.

If your dataset has multiple tables that are linked, then ReportDocument.SetDataSource() should be passed a DataSet object.

Hope this helps someone.
Title: Problem with Databse login   
Name: Chirag Rai
Date: 2004-10-15 2:29:25 AM
Comment:
Hello
i am using Crystal Report 10 & sql server 2000. In report used store procedure via "Add Command" because store procedure has parameters so it will not create parameter automatically. But when i connect from vb .net it will ask password for login and databse name is not display in database text field.
if in store procedure parameter is not theire then its not problem. And if parameter is their but i dont want to pass its value or dont need to pass value.

in report i used store procedure & table both together.

E mail : chirag@quest-software.com

please give me suggetion about the problem

Thanks

Bye
Chirag Rai
Title: Logon problem   
Name: DJ
Date: 2004-08-19 2:51:28 AM
Comment:
I have try to use your technique to log onto all tables code and still appear the logon problem. Could you show me how to use the ODBC driver to login.

Thank you very much
Title: error when binding a code-generated dataset   
Name: AaronC
Date: 2004-08-17 11:46:02 AM
Comment:
Anyone have an idea what to do if you get login errors when binding a report to a dataset (not table) that isn't pulled from a database? (Because that seems to eliminate the 2 listed problems here)
Title: But what we really want is...   
Name: Roger Hill
Date: 2004-08-17 5:44:29 AM
Comment:
This is fine as it goes, but doesn't address the real issue, which is that what I as a developer want is an easy way to take a standard Windows DB connection string (as used in .Net SqlConnection etc) and to apply this to a report that takes its data from a database.

This was quite easy to do with VB6 and CR 9. (Once you had spent a month of puzzling over the documentation, then using trial and error to find out that a call to SetTableLocation with the right parameters on each table was sufficient)

Either it is now impossible to do this with VB.Net and CR10, or I haven't managed to find the right function call.

As to why I want to swap the database connection: If it's not obvious (and it should be), consider people like me who want to do automated testing on our apps. Currently this is extremely difficult to do on any part of the app that uses crystal because we cannot easily change the database connection. (Other than doing it by hand on all of our reports, which rather defeats the point of automated testing.)
Title: my program runs fine under the vs.net environment   
Name: Simon Li
Date: 2004-08-12 11:56:50 AM
Comment:
but somehow after I deploy and install the program onto the targetmachine, It will always prompt for user name and password. my report contains tow different datasets, the following is my code.

Dim orpt As New rptEncounter

Dim ds As New DataSet
Dim sqlString As String = "SELECT * FROM Encounter INNER JOIN Patients ON Encounter.PatientID = Patients.PatientID WHERE EncounterID = " & txtEncounterID.Text
Dim da As New SqlDataAdapter(sqlString, SqlConnection1)
da.Fill(ds)
orpt.SetDataSource(ds)
Dim frm As New Print
frm.crv.ReportSource = orpt
'frm.crv.SelectionFormula = "{Encounter.EncounterID} = " & Me.txtEncounterID.Text
frm.ShowDialog(Me)

I have try different method, including using a for loop to assign logoninfos, but doesn't work at all.
Please help me to find out what's wrong with my program. thank you.
Title: Logon Error When PrintToPrinter function   
Name: Bünyamin AKYILDIZ
Date: 2004-08-12 4:00:13 AM
Comment:
This logon problem is solved for crystalReportViewer.
"CrystalReportViewer1.ReportSource = CrystalReport1;" works fine.
But if you try this code you will get still the logon error "CrystalReport1.PrintToPrinter(1,false,0,0);"
Printing the report directly to printer does not work. :(
Title: Logon Error When Showing Report   
Name: Joseph Wholey
Date: 2004-08-10 9:46:23 AM
Comment:
Can Crystal .NET show a collection?

In my application, I am working with a set of data that originated in a SQL database, but was resorted, edited, etc by the user and stored in a C# Collection datatype variable.

I created the DataSet to be used with the Solution Explorer, (right-click on the project==>Add New Item===> DataSet), and pointed it to a SQL stored procedure that would have all of the data items which I planned to have present in the later collection, just so that I could have a working report.

In a user control with the reportviewer present, I bound the collection to the report, and then the report to the reportviewer, without erroring on those lines, but when the debugger gets to the last bracket in the Page_Load function of the webform that contains the user control, I get the Logon failed message.

Have I broken any rules in this approach? Should I can the collection into a proper DataSet variable? Should I have designed the report viewer to be directly assigned to the web form?
Title: Logon Error When Binding a DataSet   
Name: Nasimul Gani
Date: 2004-08-06 10:44:42 AM
Comment:
I has been suffering for sending the dataset to crystal object. Cystal for windows form support CrystalReport1.SetDataSource(objDS) but web form does not support. Now my problems was solved by using CrystalReport1.SetDataSource(objDS.Tables(0)) at crystal object.

Thanks you very much for your excillent support.

Product Spotlight
Product Spotlight 



Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-03-28 11:38:04 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search