471,357 Members | 1,161 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

LogOn error with Crystal Report

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.LogOnExcept ion, 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
Jul 22 '05 #1
2 2216
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

"Jonathan" <jb******@britton.ca> wrote in message news:eT**************@TK2MSFTNGP10.phx.gbl...
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.LogOnExcept ion, 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
Jul 22 '05 #2
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
"Bernie Yaeger" <be*****@cherwellinc.com> wrote in message news:eD**************@TK2MSFTNGP12.phx.gbl...
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

"Jonathan" <jb******@britton.ca> wrote in message news:eT**************@TK2MSFTNGP10.phx.gbl...
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.LogOnExcept ion, 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
Jul 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Ambika Srinivasan | last post: by
1 post views Thread by Bob Skutnick | last post: by
reply views Thread by Das | last post: by
2 posts views Thread by Karun Karunakaran | last post: by
3 posts views Thread by Milan Todorovic | last post: by
19 posts views Thread by Michael O'Donnell | last post: by
1 post views Thread by vipindev.s | last post: by
reply views Thread by XIAOLAOHU | last post: by

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.