View Single Post
  #1 (permalink)  
Old June 23rd, 2004, 11:12 AM
meenakshikalera meenakshikalera is offline
Registered User
 
Join Date: Jun 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default CR8 - change location of database file / tablename

Hi!
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
Text1.Refresh
Text2.Text = myDatabaseName
Text2.Refresh
Text3.Text = myTableName
Text3.Refresh

'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
Text4.Refresh
Text5.Text = myDatabaseName
Text5.Refresh
Text6.Text = myTableName
Text6.Refresh


Next

frmViewer.Show vbModal
End Sub
--------------------------------------------------
thanks,
regards,
meenakshi