LogOn error with Crystal Report

  • Thread starter Thread starter Jonathan
  • Start date Start date
J

Jonathan

Hi all,

It's my first post here, so be kind :)

I got a little application that keep track of a small inventory, everything was going great until came the time to make some types of reports. I want to use Crystal Reports in the background to generate the reports for me, i don't want any preview, any popup (only a print dialog then send it to the selected printer). That should be pretty easy ;)

First of all, my app doesnt make any use of dataset nor dataadapter. When i retreive the data from my DB i received a collection of items (ArrayList), which, i convert back to a special dataset(only 1 table) i've created, which is bind to my CR report. Which seem to be ok, since i've managed to draw the report.

Here's the offending code ;)

ArrayList arrCuts = Data.FacadeData.Instance.GetCut(infosWireCuts);
DataCuts dataCuts = new DataCuts(); <= Creation of the temporary DS

foreach (Data.InfosWireCuts wireCut in arrCuts)
{
DataCuts.WireCutsRow rowCut= dataCuts.WireCuts.NewCutRow();

rowCut.NoCut = wireCut.NoCut;
...
(converting my arraylist into a dataset)
...

dataCuts.WireCuts.AddCutRow(rowCut);
}

InventoryReport report = new InventoryReport ();
report.PrintToPrinter(1, false, 0, 0); <= The exception is throw in here

The exception thrown is of type: CrystalDecisions.CrystalReports.Engine.LogOnException, which is a little dumb since i'm using a dataset.

If anyone have ideas or suggestions, plz tell me, it would be really apprecited...

Thx in Advance
Jonathan
 
Hi Jonathan,

There are several articles on this issue at the businessobjects.com website. Basically, what you want to do requires the establishment of logon info. (With earlier versions of CR you didn't have to do this - versions, I believe, before version X). In any case, here's the code I use for every report I run; it differs a bit from what you will do because I use the cr viewer almost exclusively, but the principle is very much the same:
Public Sub connectionchange()

Dim crtablelogoninfos As New TableLogOnInfos

Dim crtablelogoninfo As New TableLogOnInfo

Dim crconnectioninfo As New ConnectionInfo

Dim crtables As Tables

Dim crtable As Table

Dim tablecounter As Integer

crreportdocument.Load(gl_browseprintvar, OpenReportMethod.OpenReportByTempCopy)

With crconnectioninfo

..DatabaseName = "IMC"

..ServerName = globalservername

..UserID = globalusername

..Password = globalpwd

End With

crtablelogoninfo.ConnectionInfo = crconnectioninfo

crtables = crreportdocument.Database.Tables

For Each crtable In crtables

'///

If (Mid(crtable.Name, 1, 4) = "magt" Or Mid(crtable.Name, 1, 23) = "sp_createmagtbaseselect" Or Mid(crtable.Name, 1, 4) = "magb" Or Mid(crtable.Name, 1, 4) = "magf") And gl_browseprintvar = "f:\imcapps\hvsum.rpt" Then

crconnectioninfo.DatabaseName = "imc_extra"

crtablelogoninfo.ConnectionInfo = crconnectioninfo

Else

crconnectioninfo.DatabaseName = "IMC"

crtablelogoninfo.ConnectionInfo = crconnectioninfo

End If

'///

' crtablelogoninfo = crtable.LogOnInfo

' crtable.LogOnInfo.ConnectionInfo = crconnectioninfo

crtable.ApplyLogOnInfo(crtablelogoninfo)

crtable.Location = crtable.Name

'MessageBox.Show(crconnectioninfo.ServerName)

'MessageBox.Show(crtable.LogOnInfo.ConnectionInfo.ServerName)

Next

Dim subRepDoc As New ReportDocument

Dim crSection As Section

Dim crReportObject As ReportObject

Dim crSubreportObject As SubreportObject

'If you have any sub-reports, they need the connection info too...

For Each crSection In crreportdocument.ReportDefinition.Sections

For Each crReportObject In crSection.ReportObjects

If crReportObject.Kind = ReportObjectKind.SubreportObject Then

crSubreportObject = CType(crReportObject, SubreportObject)

subRepDoc = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)

For Each crtable In subRepDoc.Database.Tables

crtable.ApplyLogOnInfo(crtablelogoninfo)

crtable.Location = crtable.Name

Next

End If

Next

Next

'If CrystalReportViewer1.ParameterFieldInfo.Count > 0 Then

' CrystalReportViewer1.ShowRefreshButton = False

'End If

CrystalReportViewer1.ReportSource = crreportdocument

End Sub

HTH,

Bernie Yaeger



Hi all,

It's my first post here, so be kind :)

I got a little application that keep track of a small inventory, everything was going great until came the time to make some types of reports. I want to use Crystal Reports in the background to generate the reports for me, i don't want any preview, any popup (only a print dialog then send it to the selected printer). That should be pretty easy ;)

First of all, my app doesnt make any use of dataset nor dataadapter. When i retreive the data from my DB i received a collection of items (ArrayList), which, i convert back to a special dataset(only 1 table) i've created, which is bind to my CR report. Which seem to be ok, since i've managed to draw the report.

Here's the offending code ;)

ArrayList arrCuts = Data.FacadeData.Instance.GetCut(infosWireCuts);
DataCuts dataCuts = new DataCuts(); <= Creation of the temporary DS

foreach (Data.InfosWireCuts wireCut in arrCuts)
{
DataCuts.WireCutsRow rowCut= dataCuts.WireCuts.NewCutRow();

rowCut.NoCut = wireCut.NoCut;
...
(converting my arraylist into a dataset)
...

dataCuts.WireCuts.AddCutRow(rowCut);
}

InventoryReport report = new InventoryReport ();
report.PrintToPrinter(1, false, 0, 0); <= The exception is throw in here

The exception thrown is of type: CrystalDecisions.CrystalReports.Engine.LogOnException, which is a little dumb since i'm using a dataset.

If anyone have ideas or suggestions, plz tell me, it would be really apprecited...

Thx in Advance
Jonathan
 
Thanks you for your response... i've google around on the web before posting here... but everytime i found an page about this exception they were really accessing a sql or oracle database.

I'll try to fool around with your post, i'm pretty sure it gonna be helpful

Jonathan
Hi Jonathan,

There are several articles on this issue at the businessobjects.com website. Basically, what you want to do requires the establishment of logon info. (With earlier versions of CR you didn't have to do this - versions, I believe, before version X). In any case, here's the code I use for every report I run; it differs a bit from what you will do because I use the cr viewer almost exclusively, but the principle is very much the same:
Public Sub connectionchange()

Dim crtablelogoninfos As New TableLogOnInfos

Dim crtablelogoninfo As New TableLogOnInfo

Dim crconnectioninfo As New ConnectionInfo

Dim crtables As Tables

Dim crtable As Table

Dim tablecounter As Integer

crreportdocument.Load(gl_browseprintvar, OpenReportMethod.OpenReportByTempCopy)

With crconnectioninfo

.DatabaseName = "IMC"

.ServerName = globalservername

.UserID = globalusername

.Password = globalpwd

End With

crtablelogoninfo.ConnectionInfo = crconnectioninfo

crtables = crreportdocument.Database.Tables

For Each crtable In crtables

'///

If (Mid(crtable.Name, 1, 4) = "magt" Or Mid(crtable.Name, 1, 23) = "sp_createmagtbaseselect" Or Mid(crtable.Name, 1, 4) = "magb" Or Mid(crtable.Name, 1, 4) = "magf") And gl_browseprintvar = "f:\imcapps\hvsum.rpt" Then

crconnectioninfo.DatabaseName = "imc_extra"

crtablelogoninfo.ConnectionInfo = crconnectioninfo

Else

crconnectioninfo.DatabaseName = "IMC"

crtablelogoninfo.ConnectionInfo = crconnectioninfo

End If

'///

' crtablelogoninfo = crtable.LogOnInfo

' crtable.LogOnInfo.ConnectionInfo = crconnectioninfo

crtable.ApplyLogOnInfo(crtablelogoninfo)

crtable.Location = crtable.Name

'MessageBox.Show(crconnectioninfo.ServerName)

'MessageBox.Show(crtable.LogOnInfo.ConnectionInfo.ServerName)

Next

Dim subRepDoc As New ReportDocument

Dim crSection As Section

Dim crReportObject As ReportObject

Dim crSubreportObject As SubreportObject

'If you have any sub-reports, they need the connection info too...

For Each crSection In crreportdocument.ReportDefinition.Sections

For Each crReportObject In crSection.ReportObjects

If crReportObject.Kind = ReportObjectKind.SubreportObject Then

crSubreportObject = CType(crReportObject, SubreportObject)

subRepDoc = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)

For Each crtable In subRepDoc.Database.Tables

crtable.ApplyLogOnInfo(crtablelogoninfo)

crtable.Location = crtable.Name

Next

End If

Next

Next

'If CrystalReportViewer1.ParameterFieldInfo.Count > 0 Then

' CrystalReportViewer1.ShowRefreshButton = False

'End If

CrystalReportViewer1.ReportSource = crreportdocument

End Sub

HTH,

Bernie Yaeger



Hi all,

It's my first post here, so be kind :)

I got a little application that keep track of a small inventory, everything was going great until came the time to make some types of reports. I want to use Crystal Reports in the background to generate the reports for me, i don't want any preview, any popup (only a print dialog then send it to the selected printer). That should be pretty easy ;)

First of all, my app doesnt make any use of dataset nor dataadapter. When i retreive the data from my DB i received a collection of items (ArrayList), which, i convert back to a special dataset(only 1 table) i've created, which is bind to my CR report. Which seem to be ok, since i've managed to draw the report.

Here's the offending code ;)

ArrayList arrCuts = Data.FacadeData.Instance.GetCut(infosWireCuts);
DataCuts dataCuts = new DataCuts(); <= Creation of the temporary DS

foreach (Data.InfosWireCuts wireCut in arrCuts)
{
DataCuts.WireCutsRow rowCut= dataCuts.WireCuts.NewCutRow();

rowCut.NoCut = wireCut.NoCut;
...
(converting my arraylist into a dataset)
...

dataCuts.WireCuts.AddCutRow(rowCut);
}

InventoryReport report = new InventoryReport ();
report.PrintToPrinter(1, false, 0, 0); <= The exception is throw in here

The exception thrown is of type: CrystalDecisions.CrystalReports.Engine.LogOnException, which is a little dumb since i'm using a dataset.

If anyone have ideas or suggestions, plz tell me, it would be really apprecited...

Thx in Advance
Jonathan
 
Back
Top