Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > Crystal Reports
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Crystal Reports General discussion about Crystal Reports. For discussions specific to the book Professional Crystal Reports for VS.NET, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Crystal Reports section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 7th, 2007, 12:41 PM
Registered User
Join Date: Jul 2004
Location: Batavia, IL, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to clflyer
Default Deploy CR with Visual Studio 2005 VB.Net

I have a program that I wrote that uses CR for Visual Studio .Net with a report in it. Everything works great on the development PC.

However when I Build the program for deployment to other PCs. It retains the path to the database on my PC. How do I change the path for the report to be something like:
Application.StartupPath & "\Database\Mydatabase.mdb

I've changed the report source to point at it, (crystalReportViewer1.ReportSource = " & Application.StartupPath & "MyReport"), but it still is trying to log on to c:\VB\Myproject\bin\Debug\Mydatabase.mdb.


After many attempts and internet searches I finally found some code that works. I'd like to Credit Imran A Momin with solving my problem. Here is the code:
Imports System.Data.OleDb
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

Public Class Form1
    Dim rpt As New CrystalReport1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim path1 As String = My.Application.Info.DirectoryPath '' path

        ' OLEDB Connection

        Dim Conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " & _
        "Data Source=|DataDirectory|\General.mdb;")

        ' SQL Command
        Dim Cmd As New OleDbCommand("SELECT * from ACCUM")

        Cmd.CommandType = CommandType.Text '' command type
        Cmd.Connection = Conn '' give connection to command
        Dim adp As New OleDbDataAdapter '' declare adapter
        adp.SelectCommand = Cmd '' select command for adpapter to work on
        Dim ds As New DataSet '' delcare dataset
        adp.Fill(ds, "Crystal") '' fill the dataset through adapter


            ' change the path of the database
            rpt.DataSourceConnections.Item(0).SetConnection("" , "" & path1 & "\General.mdb", False)

        Catch exp As Exception


        End Try

        rpt.SetDataSource(ds) ' set the Dataset for the report
        CRV.ReportSource = rpt ' Load the report into the viewer

    End Sub


End Class
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
debugging in visual studio.net 2005 wendy elizabeth Visual Studio 2005 1 June 28th, 2007 10:58 PM
Visual Studio 2003 vs. Visual Studio 2005 eitanbarazani C# 2005 4 May 9th, 2006 01:34 AM
Visual Studio .net2003 and Visual Studio 2005 Gert Visual C++ 1 January 24th, 2006 05:10 AM

All times are GMT -4. The time now is 10:25 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.