on 01-21-2011 2:35 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
I get Invalid report file path on line 21.
Edited by: Dan Maresca on Jan 21, 2011 6:10 PM
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
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.