Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Generating Report on MTS server and passing it to client

Generating Report on MTS server and passing it to client

Generating Report on MTS server and passing it to client

I have an MTS server, on which my reportgeneration component resides.It has API calls to start crystal engine and generate a crystal report on MTS itself. Now i want to tranfer that file in the same format ( crystal .rpt) to the client , who ever has invoked it. I am not using any report server ( like actuate or seagateinfo) . Its just Crystal report.also there can be no drive mapping between MTS and client machines. How can i tranfer the file . FTP is one option.
Is anybody aware of any other option.

Pl. Help


RE: Generating Report on MTS server and passing it to client

I've done that before a VB application.  The client calls a MTS dll class method that has a return type of "Variant."  The MTS method a) generates a Crystal report 2) reads the Crystal report file into a byte array using VB's "Get" function c) returns the byte array to the caller as the return value of the function.

Once the variant has returned to the client, it converts the variant back to a byte array and writes the byte array to a file locally using VB's "Put" function.  You can then display the file in the Crystal Reports viewer control on a form.  You could probably pass the byte array back using a Property Bag for better performance, but I have not yet tried that as of yet.

Here's an example:

MTS Function:
Public Function GetReport() as Variant

   Dim bteCrystalRpt() as Byte
   Dim intFreeFile as Integer
   Dim strTempFilename as String

   ' <Code that generates the Crystal
   ' report here...>

   ' *Assume the path to the Crystal
   ' report is held in the variable "strTmpFileName"
   ' Redimension the array to the size it will need
   ' to store the Crystal report.
   ReDim bteCrystalRpt(FileLen(strTmpFileName) - 1) As Byte
   ' Open the Crystal report file.
   intFreeFile = FreeFile
   Open strTmpFilename For Binary Access Read As  #intFreeFile
   ' Get the contents of the file into a byte array
   Get #intFreeFile, , bteCrystalRpt
   ' Close the file and delete it.
   Close #intFreeFile
   ' Clean up...
   Kill strTmpFilename
   Erase bteCrystalRpt

   ' Return the byte array as a variant
   ' to the client.
   GetReport = bteCrystalRpt

End Function

Client Function:
Private Sub GoGetReport()

   Dim X as SampleDLL.ReportMaker ' your MTS class object
   Dim vntCrystalRpt as Variant
   Dim bteCrystalRpt() as Byte
   Dim intFreeFile as Integer

   ' Call the MTS function to retrieve
   ' the Crystal report as a variant.
   Set X = CreateObject("SampleDLL.ReportMaker")
   Set vntCrystalRpt = X.GetReport()
   ' Convert the variant to a byte array
   ' before you write it to disk, or Crystal
   ' will have errors trying to open the file.
   bteCrystalRpt = vntCrystalRpt

   ' Now write the byte array to disk
   Open "C:\MyReport.rpt" For Binary As #intFreeFile
   Put #intFreeFile, , bteCrystalRpt
   Close #intFreeFile
   ' Clean up...
   Erase bteCrystalRpt
   Set vntCrystalRpt = Nothing

   ' <Code to bring the Crystal Reports file
   ' into the Crystal viewer control here>

End Sub

RE: Generating Report on MTS server and passing it to client

Thanx a tonnnnn specise
I am working on it and will let u know whether it worked or not.
Just one question
There is one ERASE bteCrystalRpt command  to erase the array
this u r doing before returning it to the client.Will it still hold the value as the actual "Getreport = bteCrystalRpt" is after this Erase command????

Thanx alot again

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close