Results 1 to 9 of 9

Thread: Big Time Help Needed...

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2006
    Posts
    11

    Big Time Help Needed...

    Trying to get a vb app to spit out an XLS file using crystal reports.
    Works fine when I run it, but my user account has access to all tables and databases.

    So I 've created a new user that has same rights as I do and I need to pass these parameters to the Crystal Report.
    Below is how I am doing it and I am getting a '
    Failed to Open the connection' error.

    Any ideas as to what I can do?
    Thanks in advance.

    VB Code:
    1. Public Sub Export2XLS()
    2.  
    3. Dim sDestinationPath As String
    4. sDestinationPath = destination path
    5.  
    6. 'Open the report
    7. Set CrystalReport = CrystalApp.OpenReport(rptpath)
    8.  
    9.  
    10. With CrystalReport.Database
    11. .LogOnServer "PDSODBC.DLL", "SCOPACESQLP1", "crystal", "VBapp_2006", "PACE_VBpw1"
    12. End With
    13.  
    14. Set CrystalExportOptions = CrystalReport.ExportOptions
    15. DoEvents
    16. CrystalExportOptions.ExcelMaintainColumnAlignment = True
    17. DoEvents
    18. CrystalExportOptions.ExcelConstantColumnWidth = 500
    19. DoEvents
    20. CrystalExportOptions.FormatType = crEFTExcel80
    21. DoEvents
    22. CrystalExportOptions.ExcelPageBreaks = False
    23. DoEvents
    24. CrystalExportOptions.DestinationType = crEDTDiskFile
    25. DoEvents
    26. CrystalExportOptions.DiskFileName = sDestinationPath
    27. 'Export the report without prompting the user
    28. DoEvents
    29. CrystalReport.Export False
    30. End Sub
    Last edited by RobDog888; Jul 10th, 2006 at 11:52 AM. Reason: Added [vbcode] tags

  2. #2
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Big Time Help Needed...

    First of all, you are using DoEvents waaaaay too many times. DoEvents is one of the slowest executing functions in VB, and should be used once in your case, or if used in an infinite loop, once per frame. Also, in VBForums, try putting your code in [vbcode] [/vbcode] tags so it looks more readable like so:

    VB Code:
    1. Public Sub Export2XLS()
    2.  
    3.      Dim sDestinationPath As String
    4.  
    5.      sDestinationPath = destination path
    6.  
    7.      'Open the report
    8.      Set CrystalReport = CrystalApp.OpenReport(rptpath)
    9.  
    10.  
    11.      With CrystalReport.Database
    12.  
    13.          .LogOnServer "PDSODBC.DLL", "SCOPACESQLP1", "crystal", "VBapp_2006",  "PACE_VBpw1"
    14.  
    15.     End With
    16.  
    17.     Set CrystalExportOptions = CrystalReport.ExportOptions
    18.  
    19.         DoEvents
    20.  
    21.         CrystalExportOptions.ExcelMaintainColumnAlignment = True
    22.  
    23.         DoEvents
    24.  
    25.        CrystalExportOptions.ExcelConstantColumnWidth = 500
    26.  
    27.        DoEvents
    28.  
    29.        CrystalExportOptions.FormatType = crEFTExcel80
    30.  
    31.        DoEvents
    32.  
    33.        CrystalExportOptions.ExcelPageBreaks = False
    34.  
    35.     DoEvents
    36.  
    37.     CrystalExportOptions.DestinationType = crEDTDiskFile
    38.  
    39.     DoEvents
    40.  
    41.     CrystalExportOptions.DiskFileName = sDestinationPath
    42.  
    43.     'Export the report without prompting the user
    44.     DoEvents
    45.  
    46.     CrystalReport.Export False
    47.  
    48. End Sub

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Big Time Help Needed...

    Also add some error handling code to identify the exact issue.

    Moved
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4

    Thread Starter
    New Member
    Join Date
    Jun 2006
    Posts
    11

    Re: Big Time Help Needed...

    I added an error.description and it read: 'Failed to open the connection'

    Which I know is the problem, but when I open the crystal report and type in the exact same info that I am passing through via VB, the report connects, opens, and looks beautiful.

    Some I'm wondering if there is something I am missing in the connection string in VB (Which I've posted) or is there some trick in Crystal that I might not know about that needs to be done?

    Thanks again. And sorry about the ugly VB code posted in the Forum. I just did a cut and paste and didn't realize it looked so ugly.

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Big Time Help Needed...

    Looks like your using an ODBCX connection on your system but do you also have it created on the other system?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6

    Thread Starter
    New Member
    Join Date
    Jun 2006
    Posts
    11

    Re: Big Time Help Needed...

    Could you explain what you mean by that?
    I've created VB apps before that can export files to xls format using the crystal, but this is the first time I've had to pass a connection string to the crystal and I'm afraid I'm starting to get totally lost here.

    Could you please explain it to me like I was 5 years old?

    Thanks.

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Big Time Help Needed...

    Ok, in CR when you were creating your report, how did you create your reports datasource?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  8. #8

    Thread Starter
    New Member
    Join Date
    Jun 2006
    Posts
    11

    Re: Big Time Help Needed...

    ODBC - Enter Connection String (driver=sql server;server=servername;database=databasename

    Then, next screen it asks for user id and password. As well as if trusted connection, which I reply no.

    which part am I doing wrong?

  9. #9
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Big Time Help Needed...

    Then you need to create that same ODBC connection on the other system(s). Its part of the pain of using ODBC.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width