Crystal Reports

T

Tim Burda

I posted this in another forum, but I'm adding it here to for more
exposure.I am using Visual Studio 2003 and trying to get Crystal
Reports to produce output. If you have any ideas, please let me know.

This is a common problem, but nobody seems to have an answer for it.

CrystalDecisions.CrystalReports.Engine.LogOnException: Logon failed.

What does that mean, specifically? What logon is failing?

Like many, I created an .xsd file to use as a schema for designing a
crystal report. I added the reference to the .xsd file by going to the
Field Explorer, then right clicking on the Database Fields menu, then
selecting "Add/Remove Databases", I add a reference to the .xsd file
from the More Data Sources-> ADO.NET (XML) option. The .xsd imports
great, I then layout the fields on the page.

Now, at runtime, I use a dataset generated by SAME function that I
originally used to create the .xsd file. When I bind the report, I get
the failure listed above. However, if I go back to the .rpt file and
remove all fields from the report, I can get the blank report to come
up (a very small victory).

Here is the code that I use to load and display the report:

test objReport = new test(); //report of type test

DataSet dsReport = BuildReportDataSet();

//dsReport.WriteXmlSchema("C:\\temp\\schema.xsd");

objReport.SetDataSource(dsReport);
crvReport.ReportSource = objReport

Any help from anyone is greatly appreciated!

Thanks -

Tim Burda
(e-mail address removed)
 
B

Brian Fulford

This has to do with the report itself logging on to the SQL server or
whatever DB you are using. When you designed the report you set up
connection information to pull the tables and fileds over from the DB. I
havent used datasets to bind to the report.. however you may still need to
"logon" to the tables in the dataset as you do when having the report PULL
data from the database.

Private Sub SetDBLogonInfo(ByRef CRReport As
CrystalReports.Engine.ReportDocument, Optional ByVal SubReport As String =
"")

Dim mySubReports As CrystalReports.Engine.ReportDocument

Dim myTable As CrystalReports.Engine.Table

Dim myTableLogonInfo As TableLogOnInfo

Dim myConnectionInfo As ConnectionInfo

Dim TableCount As Integer = 0

Dim servername, dbname, username, pwd As String

myTableLogonInfo = New TableLogOnInfo

myConnectionInfo = New ConnectionInfo

Try

myConnectionInfo.ServerName = getServerName

myConnectionInfo.DatabaseName = getDBName

myConnectionInfo.UserID = getUserName

myConnectionInfo.Password = getPwd

If Trim(SubReport) <> "" Then

TableCount = CRReport.OpenSubreport(SubReport).Database.Tables.Count

Else

TableCount = CRReport.Database.Tables.Count

End If

For i As Integer = 0 To TableCount - 1

If Trim(SubReport) <> "" Then

myTable = CRReport.OpenSubreport(SubReport).Database.Tables(i)

Else

myTable = CRReport.Database.Tables(i)

End If

myTableLogonInfo.ConnectionInfo = myConnectionInfo

myTable.ApplyLogOnInfo(myTableLogonInfo)

If myTable.TestConnectivity Then

Dim mes As String

mes = "YESSSS"

End If

Next

Catch ex As Exception

End Try

End Sub
 
T

Tim Burda

Thanks for the response, however, I NEVER connected to a database to
build the report - that's what makes the whole thing so screwy. I
created a .xsd and built the report based on the field definition in
..xsd file. I actually got past this problem, and below is a
description of what I did to solve the problem.

The problem for me seemed to be where I was choosing the data source
from. When you are adding a data source to the report, I selected
"More Data Sources->ADO.NET (XML)" which is correct to load the .xsd
file into the window, but DO NOT MOVE the table into "Selected Tables"
list box from this entry. Instead, go up to the "Project Data->Current
Connections" and highlight the DataSet which was loaded in via the.xsd
and then move it to the "Selected Tables" list. At this point, you can
layout the columns in the report designer. I have no friggin' idea why
this worked, and I can only hope I will be able to replicate the
success I've just had.

**Actually, this does in fact seem to work as I just reproduced it.

Good luck.

If you have questions, please post a followup and I'll try and answer
them (questions must be limited to this topic - I don't know Crystal
for jack!)

Tim
 

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