
Crystal Reports Database location problem
Quote:
> I am having a problem with a program I am writing using a report created
in
> the crystal reports that comes with VB4.0 Pro. After I install the
program
> on the target system and I try to call the report I get a,
> Run Time Error 20534
> Error Detected by Database DLL
> I have the database in the same directory the report file and the program
> EXE are located in. Is there a setting in crystal reports to tell it to
> look in the current dir?
Dan:
BTDT. In my current project, I keep the report in the application
directory. The user can put his/her database where-ever they wish, but the
reports, written by me, are packaged and shipped with the application. As
such, I use App.Path to determine where they are. The code is very rough
and not at all complete, but it works. What is missing is error
checking... oops... hey, it's just a sample....
If you are using the custom control, simply set the DatabaseName member
of the control, if you
are using the API, (note this, is version CRW 5.0) the following code may
point you in the right direction.
Private Sub cmdView_Click()
Dim strPathName As String
Dim hJob As Integer
Dim iResult As Integer
Dim SessionInfo As PESessionInfo
Dim TitleHandle As Long, TitleLength As Integer, ReportTitle As String
Dim tableLocation As PETableLocation
Dim paramInfo As PEParameterFieldInfo
Dim paramCount As Integer
Dim iCurParam As Integer
Dim strIncluded As String
'''' Much has been removed from this sample in order to make it
readable.....
If (Right$(App.Path, 1) <> "\") Then
strPathName = LCase(App.Path) + "\" 'handles the root
Else
strPathName = LCase(App.Path)
End If
hJob = PEOpenPrintJob(strPathName & "Calendar.rpt")
tableLocation.StructSize = PE_SIZEOF_TABLE_LOCATION
iResult = PEGetNthTableLocation(hJob, 0, tableLocation)
tableLocation.Location = DBName & Chr$(0)
iResult = PESetNthTableLocation(hJob, 0, tableLocation)
''' Snip '''
iResult = PEOutputToWindow(hJob, "Calendar Report", 50, 50, _
Me.Width \ Screen.TwipsPerPixelX, Me.Height \ Screen.TwipsPerPixelY, _
0, frmSRSMDI.hMainWnd)
iResult = PEStartPrintJob(hJob, True)
PEClosePrintJob hJob
End Sub