Skip to Content
0
Former Member
Feb 02, 2011 at 03:46 PM

[Crystal Report 13.0.2000.0 & VB 2010] - Database connection from VB Code

299 Views

Hi,

i want establish a connection between report and MsAccess database using source code in VB .NET 2010 listed below:

***********************************************************************************

Imports CrystalDecisions.CrystalReports.Engine

Imports CrystalDecisions.Shared

Public Class Form1

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Dim crtableLogoninfos As New TableLogOnInfos()

Dim crtableLogoninfo As New TableLogOnInfo()

Dim crConnectionInfo As New ConnectionInfo()

Dim CrTables As Tables

Dim CrTable As Table

Dim crReportDocument As New CrystalReport()

With crConnectionInfo

.ServerName = "c:\db.mdb"

.DatabaseName = "db.mdb"

.UserID = ""

.Password = ""

End With

CrTables = crReportDocument.Database.Tables

For Each CrTable In CrTables

crtableLogoninfo = CrTable.LogOnInfo

crtableLogoninfo.ConnectionInfo = crConnectionInfo

CrTable.ApplyLogOnInfo(crtableLogoninfo)

CrTable.Location = crConnectionInfo.DatabaseName

Next

CrystalReportViewer1.ReportSource = crReportDocument

End Sub

End Class

***********************************************************************************

This code work fine but the database connection parameters prompt every time on runtime!

HELP ME!