Solved

CrystalReport in Visual Basic

Posted on 2011-09-08
1
396 Views
Last Modified: 2012-05-12
I have a visual basic.net (2008) that will run Crystal Reports against a sql database.  This works fine.  I can not get Visual baisc to run a crystal report against a Visual FoxPro database / table.  There is only one table linked to the report.  The crystal report runs fine in the Crystal Report developer.  All connections are made and the information is updated and correct.  If I do not use the "refresh" in the VB code, the viewer will pull the last report run and display it.  If the "refersh" is added (see the attached code), it pops up and ask for log in information.  Everything that I have tried gives me the "Log On Failed" box.  I am trying to supply the correct connection information in the code, but nothing works.  I think foxpro does not require a uer id or passwork (?).  Again the Crystal Report runs fine in the developer.  My code is below.  Thanks for any help


Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

Public Class Form1
    ' Added reference to CrystalDecisions.CrystalReports.Engine
    ' Added reference to CrystalDecisions.ReportSource
    ' Added reference to CrystalDecisions.Shared

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim icon As String
        Dim strreportname As String = "g:\Ft9 reports - 2008\employee_list_test.rpt"
        Dim ii As CrystalDecisions.Shared.TableLogOnInfo
        Dim ci As CrystalDecisions.Shared.ConnectionInfo
        Dim cr As New CrystalDecisions.CrystalReports.Engine.ReportDocument


        cr.Load(strreportname)
        cr.Refresh()
        CrystalReportViewer1.ReportSource = cr
        CrystalReportViewer1.Visible = True

        ii = cr.Database.Tables(0).LogOnInfo
        ci = ii.ConnectionInfo
        icon = "Driver={Microsoft Visual FoxPro Driver};SourceType=DBC;SourceDB=f:\gashouse\maint.dbc;Exclusive=No;"
        icon = icon & "NULL=NO;Collate=Machine;BACKGROUNDFETCH=NO;DELETED=NO"
        ci.ServerName = icon
        ci.DatabaseName = "maint"
        ci.UserID = ""
        ci.Password = ""
        ci.IntegratedSecurity = False

        cr.Database.Tables(0).ApplyLogOnInfo(ii)

    End Sub
0
Comment
Question by:Tomwo
[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
1 Comment
 
LVL 29

Accepted Solution

by:
Olaf Doschke earned 500 total points
ID: 36508466
The login might be a windows dialog asking for login to the directory f:\gashouse\. While VFP does not have any security aspects, the file system has.

I don't have crystal to check how it would behave. Using VFP to connect to a dbc in a folder I have removed access rights, I don't get a connection, but also no dialog. Instead VFP get's an ODBC error and the ODBC driver error message simply is: "Connectivity error: [Microsoft][ODBC Visual FoxPro Driver]Cannot open file c:\secure\secure.dbc"

If setting file/folder access permissions does not work out, then what version is the {Microsoft Visual FoxPro Driver} you use?

Bye, Olaf.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 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