cancel
Showing results for 
Search instead for 
Did you mean: 

CR Viewer in VB.NET 2010

Former Member
0 Kudos

For the life of me, I cannot get the viewer to logon to the database automatically instead of prompting me all the time.

It is a MS Access Database, ADO.

Thank you in advanced.

Dan

Public Class ReportApp

Private rptDocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument

Private Sub objTree_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles objTree.DoubleClick

If objTree.SelectedNode.Text = "Item List Template" Then

rptDocument.Load("C:\Users\Owner\documents\visual studio 2010\Projects\cmxReporting\cmxReporting\CrystalReport1.rpt")

With rptDocument.DataSourceConnections(0)

Dim strDBName As String = .DatabaseName

Dim blnIntegrated As Boolean = .IntegratedSecurity

.SetConnection("C:\ICOM\Database\CBODef_s.mdb", strDBName, blnIntegrated)

End With

rptDocument.Refresh()

End If

End Sub

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

What connection type is the report using to connect to the database (Native, OLE DB, ODBC)?

What version is the Access DB?

What OS are you on?

Is the Access DB secured?

What version of CR was the report created in?

Does the report work in the CR designer?

Search the forums for Access - fair bit of info on connecting to Access

Ludek

Follow us on Twitter http://twitter.com/SAPCRNetSup

Got Enhancement ideas? Try the [SAP Idea Place|https://ideas.sap.com/community/products_and_solutions/crystalreports]

Edited by: Ludek Uher on Jan 21, 2011 7:47 AM

Former Member
0 Kudos

What connection type is the report using to connect to the database (Native, OLE DB, ODBC)? OLE DB

What version is the Access DB? 97/2003/2007

What OS are you on? Windows XP

Is the Access DB secured? Yes, password C0mtrex

What version of CR was the report created in? 2010

Does the report work in the CR designer? Yes

former_member183750
Active Contributor
0 Kudos

Try:





Dim crDatabase As Database 
    Dim crTables As Tables 
    Dim crTable As Table 
    Dim crTableLogOnInfo As TableLogOnInfo 
    Dim crConnectioninfo As ConnectionInfo 

 crConnectionInfo = New ConnectionInfo() 
        With crConnectionInfo 
            .ServerName = "Server1" 
            .DatabaseName = "Pubs" 
            .UserID = "myuser" 
            .Password = "mypassword" 
        End With 

        'Get the tables collection from the report object 
        crDatabase = crReportDocument.Database 
        crTables = crDatabase.Tables 

        'Apply the logon information to each table in the collection 
        For Each crTable In crTables 
            crTableLogOnInfo = crTable.LogOnInfo 
            crTableLogOnInfo.ConnectionInfo = crConnectionInfo 
            crTable.ApplyLogOnInfo(crTableLogOnInfo) 
        Next 

    CrystalReportViewer1.ReportSource = crReportDocument



Also, see the samples [here|https://wiki.sdn.sap.com/wiki/display/BOBJ/CrystalReportsfor.NETSDK+Samples]

vbnet_win_dbengine.zip is one of the better ones to look at.

If you are using Integrated Security, see [this|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/b021e47e-be1d-2b10-c6b2-efa9db3abd6b] article.

- Ludek

Edited by: Ludek Uher on Jan 21, 2011 8:01 AM

Former Member
0 Kudos

http://pastie.org/1484714

I get Invalid report file path on line 21.

Edited by: Dan Maresca on Jan 21, 2011 6:10 PM

former_member183750
Active Contributor
0 Kudos

umm, so where are you loading the report?

Former Member
0 Kudos

What do you mean? What did I miss?

This is my current code, the .rpt is in C:\ICOM\Reports\CrystalReport1.rpt

Imports CrystalDecisions.CrystalReports.Engine

Imports CrystalDecisions.Shared

Public Class ReportApp

Private Sub objTree_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles objTree.DoubleClick

Dim crDatabase As Database

Dim crTables As Tables

Dim crTable As Table

Dim crLogonInfo As TableLogOnInfo

Dim crConnectionInfo As ConnectionInfo

Dim crReportDocument As New ReportDocument

crConnectionInfo = New ConnectionInfo()

If objTree.SelectedNode.Text = "Item List Template" Then

With crConnectionInfo

.ServerName = "C:\ICOM\Database\CBODef_s.mdb"

.DatabaseName = "C:\ICOM\Database\CBODef_s.mdb"

.UserID = ""

.Password = "C0mtrex"

End With

crDatabase = crReportDocument.Database

crTables = crDatabase.Tables

For Each crTable In crTables

crLogonInfo = crTable.LogOnInfo

crLogonInfo.ConnectionInfo = crConnectionInfo

crTable.ApplyLogOnInfo(crLogonInfo)

Next

crViewer.ReportSource = crReportDocument

End If

End Sub

End Class

Edited by: Dan Maresca on Jan 21, 2011 11:41 PM

former_member183750
Active Contributor
0 Kudos

umm, it's been a long day so maybe I'm missing something. Where is:

crReportDocument.Load("C:\ICOM\Reports\CrystalReport1.rpt")

E.g.; you have:

crViewer.ReportSource = crReportDocument

Where is crReportDocument defined / loaded?

??

- Ludek

Former Member
0 Kudos

Thank you! Forgot that part, I put it before the crDatabase = crReportDocument.Database line

Hugs

Answers (0)