Created
April 23, 2015 11:05
-
-
Save facebookegypt/39904487683804c031df to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'This code won't work with Protected MS-Access Database with Password | |
'VB 2010 Crystal Report MS-Access 2003/2007/2010 | |
'adonetaccess2003.blogspot.com | |
Imports CrystalDecisions | |
Imports CrystalDecisions.CrystalReports.Engine | |
Imports CrystalDecisions.Shared | |
Public Class Report1 | |
Private Sub CrystalReportViewer1_Load(sender As Object, e As System.EventArgs) Handles CrystalReportViewer1.Load | |
Dim CrTables As Tables | |
Dim crtableLogoninfo As New TableLogOnInfo | |
Dim crConnectionInfo As New ConnectionInfo | |
Try | |
'reportdoc object | |
Dim cryRpt As New ReportDocument | |
'load report | |
cryRpt.Load("Reports Location + Report File.Rpt") | |
'parameters definition(if any) | |
'provide connection info. This is important and you can change it as per your db location | |
With crConnectionInfo | |
.ServerName = "Database locatoion + file.accdb or file.mdb" | |
.DatabaseName = "Same as ServerName for MS-Access" | |
.UserID = "Your UserID here" | |
.Password = "Your Database Password here" | |
End With | |
CrTables = cryRpt.Database.Tables | |
For Each CrTable As Table In CrTables | |
crtableLogoninfo = CrTable.LogOnInfo | |
crtableLogoninfo.ConnectionInfo = crConnectionInfo | |
CrTable.ApplyLogOnInfo(crtableLogoninfo) | |
Next | |
CrystalReportViewer1.ReportSource = cryRpt | |
CrystalReportViewer1.Refresh() | |
Catch ex As Exception | |
MsgBox(ex.Message) | |
End Try | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment