Solved

Accessing a MSSQL Server via ODBC in VB6

Posted on 2002-06-14
4
513 Views
Last Modified: 2007-11-27
I have a VB6 app developed that calls an embedded Crystal 8.5 report.  The report is set to use a System DSN via RDO to access a MSSQL server.  The report and app work fine on the development machine.  I installed the app to a second machine that will need to access a different database than the one that was used to write the report.  When I call the report, I receive a "Database Error" message that contains no further information.  Then after accepting that message, the "Server has not yet been opened" error message comes up.  I can save the embedded report as an rpt file and it runs fine on both machines.  I have even renamed the db on the second machine to match the original and reset the ODBC driver but still get the same message.  Any ideas or suggestions are appreciated.  Thanks
0
Comment
Question by:cojo1976
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 1

Expert Comment

by:Chess
ID: 7079373
How are you passing the connection information to the report?  It would help if you post your code.
0
 

Author Comment

by:cojo1976
ID: 7079460
I assume that my problem is that my very limited understanding of this control(first time I have tried to integrate CR into VB) was that the crystal control handled that and it did not have to be coded.  However, I have since tried setlogoninfo and logonserver.  When I use the setlogoninfo method the report returns the message "MSRDO20.DLL" "37000 [Microsoft][ODBC SQL Server Driver][SQL Server] The cursor was not declared."  Followed by "Error detected by Database dll."  

Here is the setlogoninfo code that I used.

Dim Report As New CrystalReport1
Private Sub Form_Load()
Report.Database.Tables(1).SetLogOnInfo "ODBC", "", "user", "pwd"
Report.Database.Verify

I get the same message even if I put the db name in.
Thanks
0
 
LVL 1

Accepted Solution

by:
Chess earned 400 total points
ID: 7083609
Try something like this.  If that does not work, post your code in full.
------------------------------------------------
sreport_name = "rpt_swap_valuation.rpt"
   
    sreport_name = App.Path & "\REPORTS\" & sreport_name
   
    Set crreport = crapplication.OpenReport(sreport_name)
    For i = 1 To crreport.Database.Tables.Count
        crreport.Database.Tables(1).SetLogOnInfo gServerName, gDbName, gLogin, gPassword
        crreport.Database.Tables(1).Location = gDbName & ".dbo." & "Get_Swap_Appraisal"
    Next i
    crreport.ParameterFields(1).AddCurrentValue (sreport_fund_num)
    crreport.ParameterFields(2).AddCurrentValue (CDate(sreport_processingdate))
    crreport.ParameterFields(3).AddCurrentValue (gFundgroupnumber)
    frmReport.rptViewer.ReportSource = crreport

    frmReport.rptViewer.ViewReport
    frmReport.Show
0
 

Author Comment

by:cojo1976
ID: 7090729
This solution does accomplish the end result of opening the report from within the VB application, however it does not explain how to do it using the embedded report designer.  Thanks for you help on getting this working, I just wish I knew why it didn't work the other way.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question