Solved

Accessing a MSSQL Server via ODBC in VB6

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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. …
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 …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 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

12 Experts available now in Live!

Get 1:1 Help Now