Solved

Accessing a MSSQL Server via ODBC in VB6

Posted on 2002-06-14
4
510 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
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Crystal Reports Swap Columns 2 55
Crystal Reports 9 and Subreports 3 63
Crystal Reports Subreport details 16 57
Crystal Reports Server 2016 Installation, setup and use 5 148
Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

813 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now