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 October 1st, 2004, 03:44 AM
Authorized User
 
Join Date: Sep 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to change server and database name in CR.NET

Hi all,

 I have a crystal report that is using a SQL server stored procedure as a datasource. The problem is i have selected the server and login at design time and when I move my application onto another machine where the SQL server has another name It does not work. Is there a way of specifying the server name and the stored procedure name from the Code?



 
Old October 2nd, 2004, 02:10 AM
Registered User
 
Join Date: Aug 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, you can change the server name and stored procedure name at run time.

 1) Import "CrystalDecisions.Shared" Namespace into your code.
 2) Use the following code.

        Dim objLogonInfo as New TableLogonInfo
        objLogonInfo.ConnectionInfo.ServerName = NewServer
        objLogonInfo.ConnectionInfo.DatabaseName = NewDatabase
        objLogonInfo.ConnectionInfo.UserID = NewUserId
        objLogonInfo.ConnectionInfo.Password = NewPassword

        Dim rptDocument as ReportDocument
        rptDocument = New ReportName

        Dim intIndex as int16
        For intIndex = 0 to rptDocument.Database.Tables.count -1
            rptDocument.Database.Tables(intIndex).ApplyLogOnIn fo(objLogonInfo)
            rptDocument.Database.Tables(intIndex).Location = NewStoredProcedure
        Next

        CrystalViewer1.ReportSource = rptDocument
        CrystalViewer1.DataBind()

 
Old October 4th, 2004, 09:07 AM
Authorized User
 
Join Date: Sep 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

:D cool that worked Thanx

 
Old October 26th, 2004, 02:12 AM
Authorized User
 
Join Date: Oct 2004
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi sureshvb
i tried ur code but its not working for me

i have the same server but diff databse, they have common tablename, and design, i need to create generic report

dim objLogonInfo As New TableLogOnInfo

objLogonInfo.ConnectionInfo.DatabaseName = Module1.dbaseName

Dim rpt As New Report1
crViewer.ReportSource = rpt

our sql2000 is integrated with win2000 security settings
so i rmeoved the username,pasword

waiting for ur help,
tnx



 
Old October 27th, 2004, 09:02 PM
Authorized User
 
Join Date: Oct 2004
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

its working for me right now, but the problem is i have two table on subreport
how do i change it

tnx





Similar Threads
Thread Thread Starter Forum Replies Last Post
Recipe to change CR query at run time. dbron Crystal Reports 4 June 24th, 2009 03:07 AM
CR XI Access System database in asp.net 2.0 rturner003 ASP.NET 2.0 Professional 0 October 22nd, 2007 09:50 AM
How to change CR 11 database name at run time, ASP enghok Classic ASP Professional 3 September 26th, 2007 03:28 AM
change database location on CR 10 at run time blu3_x30n Pro VB 6 0 March 30th, 2006 01:25 PM
Change picture at run-time with CR for .NET? NTurnbullJr Crystal Reports 2 March 31st, 2005 05:29 AM





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