Crystal 8.5 and VB6 - Server has not yet been opened error

speshulk926
speshulk926 used Ask the Experts™
on
I have a few different reports that are called from a vb6 application.  They currently connect directly to the tables they need the info from for the report and I decided to convert from that to stored procedures.  I have my stored procedure ready and working and added it to my report.  It showed the fields that I put in there and I added them to my report.  I verified that report works using the username/password that my program uses to access the database inside of Crystal Reports and all looks good there.  

I didn't change anything in my code that was previously working.  Theoretically, by adding that stored proc, nothing should have changed.  However, now when I try to execute the report, I'm getting "Server has not yet been opened."  Does anyone have any suggestions on fixing this or has seen this before?
Dim crxRpt As CRAXDRT.Report
  Dim crxApp As New CRAXDRT.Application
  Dim crxTable As CRAXDRT.DatabaseTable

  Set colreport = colReports(cboReport)
  Set crxRpt = crxApp.OpenReport(App.Path & "\" & colreport.Filename)
  
  For Each crxTable In crxRpt.Database.Tables
    crxTable.SetLogOnInfo gtServer, gtDatabase, gtUserName, gtPassword
  Next

  crxRpt.DiscardSavedData

  crxRpt.EnableParameterPrompting = False
  frmReportViewer.CRViewer1.ReportSource = crxRpt
  frmReportViewer.CRViewer1.ViewReport
  frmReportViewer.Caption = colreport.Description
  frmReportViewer.Show vbModal
  Set crxRpt = Nothing

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
Do the users have permissions to the stored procedures?

mlmcc

Author

Commented:
Yes.  It uses a standard sql server login.  I ran the stored procs against the database itself with that same username and password and also added that username and password to the crystal report itself and it works fine.  It only says that error when I call the report from VB.
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
Are you changing the server? database?

mlmcc
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Author

Commented:
Same server, same database.  Which is why it's so weird.  I stepped through my code to verify that "crxTable.SetLogOnInfo gtServer, gtDatabase, gtUseerName, gtPassword" is using the same server, db, user, and pass that I am using for my stored proc.  Everything worked fine on the report prior to me changing that.

What happened is I modified the program and it was going to require several linking of tables.  Instead of trying to do that from within the Crystal GUI, I thought it'd be easier to create a stored proc (which it was easier) and link it to the Crystal Report.  I did that and literally changed nothing in my code and now it's not working.  Just trying to give you a little background info as to why I changed it.
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
If it is using the same database then you shouldn't need to do the assignment in code.

Try commenting it out

mlmcc

Author

Commented:
I commented out the following and received the exact same error message.

 For Each crxTable In crxRpt.Database.Tables
    crxTable.SetLogOnInfo gtServer, gtDatabase, gtUserName, gtPassword
  Next

I'm at a loss...
Did some more google searching today and I found a link that fixed my issue.  For any of those who find this later on, I found this link here (http://www.it-sideways.com/2009/01/server-has-not-yet-been-opened-crystal.html) that explains in detail how to fix it.  Just in case that site goes away, I'll re-post the information here...

1.  Open up Crystal Report 8.5

2.  Goto "Database/Convert Database Driver".
Reset the driver by selecting the dll file. If it is the correct dll file, select it again to reset it. If you are connecting using OLEDB, then the file should be pdsoledb.dll. This applies to MS SQL and MS Access.

3.  The next step is trickier, make sure you select only "Microsoft OLEDB Provider for SQL Server". Do not select "SQL Native Client" which will give you the "Server Has Not Been Opened" error.

4.  Click "Next" and provide the proper connection parameters for your local data source. During deployment, you must also dynamically reset the parameters to the proper one using 'SetLogOnInfo'. Check out here for sample codes (using VB6 and Crystal Report 8.5 with database of either MS Access of MSSQL).

5.  Remember to save the rpt file.

6.  You are done. Test it out at deployment machine again
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
SQL Native CLient requires you to load the MS SQL client on the user's workstation.  That requires a license for each user from M$.

mlmcc

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial