Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > Crystal Reports
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 7th, 2007, 12:41 PM
Registered User
 
Join Date: Jul 2004
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.

Bill

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

        Try

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

        Catch exp As Exception

            MsgBox(exp.Message)

        End Try

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

    End Sub

:)


End Class





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





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