PC Review


Reply
Thread Tools Rate Thread

Changeing CrystalReport.NET database in VB.NET code

 
 
Brian Henry
Guest
Posts: n/a
 
      7th Apr 2004
Is it possible to change the database in which a crystalreports.net report
is linking to? we have a bunch of reports made that pull straight form the
database server, but work with differnet versions of it (all same table
structures) such as live and development. Can you tell a report to execute
off of a different database in vb.net?


 
Reply With Quote
 
 
 
 
Bernie Yaeger
Guest
Posts: n/a
 
      8th Apr 2004
Hi Brian,

In Crystal 9 and higher (perhaps lower as well, but I'm not sure), you can
go into database/ set database location and map replacement tables and
columns, simple by selecting the one to be replaced at the top, the table to
now use at the bottom and clicking 'update'; any data mapping problems will
be highlighted and will allow for manual alteration.

HTH,

Bernie Yaeger

"Brian Henry" <brianiup[nospam]@adelphia.net> wrote in message
news:(E-Mail Removed)...
> Is it possible to change the database in which a crystalreports.net report
> is linking to? we have a bunch of reports made that pull straight form the
> database server, but work with differnet versions of it (all same table
> structures) such as live and development. Can you tell a report to execute
> off of a different database in vb.net?
>
>



 
Reply With Quote
 
Brian Henry
Guest
Posts: n/a
 
      10th Apr 2004
I need to dynamically change it though through the vb.net application im
makeing


"Bernie Yaeger" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Brian,
>
> In Crystal 9 and higher (perhaps lower as well, but I'm not sure), you can
> go into database/ set database location and map replacement tables and
> columns, simple by selecting the one to be replaced at the top, the table

to
> now use at the bottom and clicking 'update'; any data mapping problems

will
> be highlighted and will allow for manual alteration.
>
> HTH,
>
> Bernie Yaeger
>
> "Brian Henry" <brianiup[nospam]@adelphia.net> wrote in message
> news:(E-Mail Removed)...
> > Is it possible to change the database in which a crystalreports.net

report
> > is linking to? we have a bunch of reports made that pull straight form

the
> > database server, but work with differnet versions of it (all same table
> > structures) such as live and development. Can you tell a report to

execute
> > off of a different database in vb.net?
> >
> >

>
>



 
Reply With Quote
 
Bernie Yaeger
Guest
Posts: n/a
 
      10th Apr 2004
Hi Brian,

Actually, you can do that also.

Below is code I use to ensure that the tables and the database that a report
is connected to is the one I now want it to be connected to. This is
throughout my apps because I code on a system that refers to a given server
and my clients have a different name for the real server, but it has
application to exactly what you want to do. There is extraneous stuff
particular to my needs, but you'll get the point.

Let me know if you have any questions about this - I call it just before
sending the reportviewer control into action:
Public Sub connectionchange()



Dim crtablelogoninfos As New TableLogOnInfos

Dim crtablelogoninfo As New TableLogOnInfo

Dim crconnectioninfo As New ConnectionInfo

Dim crtables As Tables

Dim crtable As Table

Dim tablecounter As Integer

crreportdocument.Load(gl_browseprintvar,
OpenReportMethod.OpenReportByTempCopy)

' gl_browseprintvar is the full path and name of the .rpt file to print

With crconnectioninfo

..DatabaseName = "IMC"

..ServerName = globalservername

..UserID = globalusername

..Password = globalpwd

End With

crtablelogoninfo.ConnectionInfo = crconnectioninfo

crtables = crreportdocument.Database.Tables

For Each crtable In crtables



crconnectioninfo.DatabaseName = "IMC"

crtablelogoninfo.ConnectionInfo = crconnectioninfo




crtable.ApplyLogOnInfo(crtablelogoninfo)


crtable.Location = crtable.Name

Next

Dim subRepDoc As New ReportDocument

Dim crSection As Section

Dim crReportObject As ReportObject

Dim crSubreportObject As SubreportObject

'If you have any sub-reports, they need the connection info too...

For Each crSection In crreportdocument.ReportDefinition.Sections

For Each crReportObject In crSection.ReportObjects

If crReportObject.Kind = ReportObjectKind.SubreportObject Then

crSubreportObject = CType(crReportObject, SubreportObject)

subRepDoc = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)

For Each crtable In subRepDoc.Database.Tables

crtable.ApplyLogOnInfo(crtablelogoninfo)

crtable.Location = crtable.Name

Next

End If

Next

Next



CrystalReportViewer1.ReportSource = crreportdocument

End Sub

HTH,

Bernie Yaeger

"Brian Henry" <brian.henry[nospam]@adelphia.net> wrote in message
news:(E-Mail Removed)...
> I need to dynamically change it though through the vb.net application im
> makeing
>
>
> "Bernie Yaeger" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hi Brian,
> >
> > In Crystal 9 and higher (perhaps lower as well, but I'm not sure), you

can
> > go into database/ set database location and map replacement tables and
> > columns, simple by selecting the one to be replaced at the top, the

table
> to
> > now use at the bottom and clicking 'update'; any data mapping problems

> will
> > be highlighted and will allow for manual alteration.
> >
> > HTH,
> >
> > Bernie Yaeger
> >
> > "Brian Henry" <brianiup[nospam]@adelphia.net> wrote in message
> > news:(E-Mail Removed)...
> > > Is it possible to change the database in which a crystalreports.net

> report
> > > is linking to? we have a bunch of reports made that pull straight form

> the
> > > database server, but work with differnet versions of it (all same

table
> > > structures) such as live and development. Can you tell a report to

> execute
> > > off of a different database in vb.net?
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HELP: VBA Code to extract data from an SQL Server database and put it into Access Database Clinton M James Microsoft Excel Programming 1 8th Oct 2007 12:44 AM
how to control crystalreport non database aware Wilfried Mestdagh Microsoft C# .NET 2 2nd Nov 2006 03:44 PM
VB6 - Access ADP Database Custom Property / Or Read Line of Code In ADP Code Module WhatTha Microsoft Access VBA Modules 0 24th Jan 2006 03:26 PM
crystalReport =?Utf-8?B?cy1nYWxpdA==?= Microsoft Dot NET 0 1st Oct 2004 06:59 PM
Changeing crystal reports database connection Brian Henry Microsoft ADO .NET 0 7th Apr 2004 06:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:42 AM.