469,904 Members | 2,097 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,904 developers. It's quick & easy.

difficult question deployment with crystal reports

Hello,

I need you help with a crystal report problem. The report is very simple, and I have already done the layout. Howerver, I need to deploy. I am using crystal reports version 10.

I have found some information on the internet about using ODBC using the DNS. And using the code below to write the connection. However, I tried wroking the code but didn't work for me. Here is it anyway.

code (put in a separate module called modCrystal.vb - to keep things tidy): -

Option Explicit On
Option Strict On

Imports System
Imports CrystalDecisions.CrystalReports.Engine

Public Function LoadCrystalRPT(ByVal strReport As String) As ReportDocument
Dim cryDoc As New ReportDocument

With cryDoc
.Load(strReport)
.SetDatabaseLogon(USER_ID, PASSWORD)

' This will override the table locations
Dim cryTables As Tables = .Database.Tables
Dim cryTable As Table = Nothing

Dim cInfo As CrystalDecisions.Shared.ConnectionInfo = New CrystalDecisions.Shared.ConnectionInfo
Dim lInfo As CrystalDecisions.Shared.TableLogOnInfo = New CrystalDecisions.Shared.TableLogOnInfo

With cInfo
.ServerName = ODBC_DSN_NAME
.DatabaseName = DATABASE_NAME
.UserID = USER_ID
.Password = PASSWORD
End With

For Each cryTable In cryTables
With cryTable
lInfo = .LogOnInfo
lInfo.ConnectionInfo = cInfo
.ApplyLogOnInfo(lInfo)

.Location = DATABASE & ".dbo." & cryTable.Location
End With
Next

Return cryDoc
End With
End Function

to use: -
cryReport.ReportSource = LoadCrystalRPT("C:\path\to\report.rpt")
where cryReport is the crystal reports viewer component.
==============
this code is for Crystal Reports v11, it may work with v10
but i can't guarantee it
==========================

I am not sure if the above method is the best, and the above is complicated for me to understand. Do you have any examples in using dataset or other methods? What is the industry method of doing this?

Thanks in advance,

Steve
Oct 25 '06 #1
0 1364

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Gudni G. Sigurdsson | last post: by
3 posts views Thread by Dmitry Karneyev | last post: by
2 posts views Thread by Mika M | last post: by
1 post views Thread by wtistang | last post: by
reply views Thread by Akut | last post: by
3 posts views Thread by Greg Smith | last post: by
1 post views Thread by =?Utf-8?B?Q2lhcmFuIE8nJ0Rvbm5lbGw=?= | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.