Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Crystal Report / November 2004



Tip: Looking for answers? Try searching our database.

Changing Database Location at Runtime for Crystal 10

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Timothy Anyona - 23 Nov 2004 14:27 GMT
Hi,
I have tried using a number of methods to change the database location
of a report from code without luck. I've used the SetLogonInfo method
and tried using the ConnectionProperty object. The connection
information for the table objects within the report changes but the
report still gets data from the database  that was used when the
report was created. The report's SQLQueryString property remains
unchanged whatever I try. I'm stumped. I'd appreciate any ideas.
I'm connecting to a SQL Server 2000 database, using VB6 and Crystal
Reports 10.

Timothy.
Gary Warner - 27 Nov 2004 15:08 GMT
I'm using
Visual Basic 6
Crystal Reports 9.0   (OLE DB (ADO) and Microsoft Jet 4.0 database
connection)
Access 1997 with password
MDAC 2.5

The code below works for me. It specifies the "Date Source"
giving it a path and MDB file name.

NOTE: gAppPath is just a global string variable that holds the path to
           the directory of the MDB that I want to use.

I hope this helps you.
Gary

-------------------------------

Public Sub DisplayReport(ReportFileName As String)
 Set Report = Application.OpenReport(gReportPath & ReportFileName)
 Screen.MousePointer = vbHourglass
 CRViewer91.ReportSource = Report
 Report.DiscardSavedData
 Report.Database.Tables(1).ConnectionProperties.ITEM("Data Source") =
gAppPath & "MARS.mdb"
 Report.Database.Tables(1).ConnectionProperties.ITEM("Jet Database
Password") = "PASSWORD"
 CRViewer91.Refresh
 CRViewer91.ViewReport
 Screen.MousePointer = vbDefault
 Me.Top = 0:    Me.Height = Screen.Height * 0.9
 Me.Left = 0:   Me.Width = Screen.Width * 0.75
 Me.Show vbModal
End Sub
Timothy Anyona - 29 Nov 2004 11:12 GMT
Hi,
Thanks for your response. I didn't quite try your solution seeing as I
need to connect to a SQL Server DB. However, I found a couple of
things that work for me. AFter using SetLogonInfo, set the table
location for each table to its fully qualified name. ie.

For all tables in the report
dbTable.SetLogOnInfo TheServer, TheDB, "<User_ID>", "<PWD>"
dbTable.Location = TheDB & "<Table_Owner>" & dbTable.Name

where dbTable is a reference to a table in the report and Table_Owner
is the owner of that table e.g. "dbo".

The other thing you can do is to set the "Overridden Qualified Table
Name" property for all tables in your report from the Crystal REports
designer. Select the Database | Set Database Location menu and expand
the table name in the treeview to get this property.
After almost giving up on this issue (and thinking of asking for a
refund from Business Objects), I almost feel like a fool.
You live, you learn. I hope other guys can benefit from my experience.

Timothy.

> I'm using
> Visual Basic 6
[quoted text clipped - 30 lines]
>   Me.Show vbModal
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2012 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.