p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Crystal Reports (http://p2p.wrox.com/forumdisplay.php?f=113)
-   -   CR8 - change location of database file / tablename (http://p2p.wrox.com/showthread.php?t=14570)

meenakshikalera June 23rd, 2004 11:12 AM

CR8 - change location of database file / tablename
I have just started using Crystal Reports 8 with VB 6...I have some Report templates already made in VB6...while making those reports tables were created as follows:

Server Type: ODBC MS Access 97 Database
Server Name: MS Access 97 Database
Database: V:\meenakshi\system1.mdb (some mapped drive from another computer)
User ID: Admin

Now say, i want to run this project on the client side...obviously in that case, the server name (here it is access so may not change, but in the case of ms sql server 2000, the server name may change), database would change....
i want all my templates to still run....how is that possible...i have written the following piece of code, but it is still not working...i have searched lots on the forums etc. but i am sure i am missing somethind very minute somewhere....pasted below is my code:
Dim crxApplication As New CRAXDRT.Application
Public Report As CRAXDRT.Report
Dim crxDatabaseTable As CRAXDRT.DatabaseTable
Dim crxParameterField As CRAXDRT.ParameterFieldDefinition
Dim crxFormulaField As CRAXDRT.FormulaFieldDefinition
Dim cTable As CRAXDRT.DatabaseTable

Dim myServerName As String
Dim myDatabaseName As String
Dim myTableName As String

Private Sub Form_Load()

' this rptReport1 report is prepared using EMPLOYEE table in the System1.mdb and i want to change it to use the CUSTOMER table in Sytem1.mdb at runtime or i want to change the location of my database file System1.mdb from V:\meenakshi to some other place

Set Report = crxApplication.OpenReport ("V:\meenakshi_Conversion\rptReport1.rpt", 1)

frmViewer.Show vbModal

For Each cTable In Report.Database.Tables

myServerName = cTable.LogOnServerName
myDatabaseName = cTable.LogOnDatabaseName
myTableName = cTable.Name
myLocation = cTable.Location

' i am just printing the servername, database name and tablename that r currently used in the rpt
Text1.Text = myServerName
Text2.Text = myDatabaseName
Text3.Text = myTableName

'now i want to change the table name to CUSTOMER .... rest everything remains same ...or may be i move my database file, that is System1.mdb somwhere else and try to ask the report to use this database location now... in that case, table name remains same but database name changes to reflect the new location
cTable.Name = "EMPLOYEE"
cTable.Location = cTable.Name
cTable.SetLogOnInfo myServerName, myDatabaseName, "admin", ""
myServerName = cTable.LogOnServerName
myDatabaseName = cTable.LogOnDatabaseName

' i am just printing the servername, database name and tablename that r now used in the rpt
myTableName = cTable.Name
Text4.Text = myServerName
Text5.Text = myDatabaseName
Text6.Text = myTableName


frmViewer.Show vbModal
End Sub

All times are GMT -4. The time now is 02:34 AM.

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