Hey guys, its several months i can not find any solution for this problem, I really need help.
I try to ask this question clear and provide everything's you need, although I know its a little confusing but please help me.
I work on a project with VB6 and Crystal Reprt 8.5, everything work fine with normal reports but my code need a little modify to work with reports that contain subreport, I can not set servername, username and password of database for subreport through VB6 and it crush when I run my project.
Here is my code, I really dont know what is this because someone else (my co worker) wrote it, but if you help me I can provide more informations:
Thank you very much
I try to ask this question clear and provide everything's you need, although I know its a little confusing but please help me.
I work on a project with VB6 and Crystal Reprt 8.5, everything work fine with normal reports but my code need a little modify to work with reports that contain subreport, I can not set servername, username and password of database for subreport through VB6 and it crush when I run my project.
Here is my code, I really dont know what is this because someone else (my co worker) wrote it, but if you help me I can provide more informations:
Code:
Global CurrentJob As Integer
CurrentJob = PEOpenPrintJob(AppPath & "Report.rpt")
TableCount = PEGetNTables(CurrentJob)
'loop through all tables in the main report and set connection information
For i = 0 To (TableCount - 1)
'set the table number
TableNum = i
call setParameters
Next i
PEOutputToWindow(CurrentJob , "Title", 0, 0, 4330, 1080, 0, 0)
PEStartPrintJob(CurrentJob , False)
PEClosePrintJob (CurrentJob )
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
private sub setParameters
Dim LogOnInfo As PELogOnInfo
Dim TableLoc As PETableLocation
TableLoc.StructSize = PE_SIZEOF_TABLE_LOCATION
LogOnInfo.StructSize = PE_SIZEOF_LOGON_INFO
LogOnInfo.ServerName = ServerName & Chr(0)
LogOnInfo.DatabaseName = DatabaseName & Chr(0)
LogOnInfo.F_UserID = SqlUser & Chr(0)
LogOnInfo.Password = sqlPwd & Chr(0)
PEGetNthTableLocation(CurrentJob, TableNum, TableLoc)
PESetNthTableLogOnInfo(CurrentJob, TableNum, LogOnInfo, True)
'set table name
'I really dont know what is followin lines and what he tried to do
Dim H, hg
H = InStr(1, TableLoc.Location, ".dbo")
hg = DatabaseName & Right(TableLoc.Location, Len(TableLoc.Location) - H + 1) ' "acc81.dbo.ftaraz"
TableLoc.Location = hg & Chr(0)
PESetNthTableLocation(CurrentJob, TableNum, TableLoc)
end sub '//end setParameters sub