[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 239
  • Last Modified:

How to create the cyrstal report for given input text file in VB.NET(Urgent)

Hi,
I want to create the crystal report for a text file....
But don't want to use the ODBC....
If i use the Access/Excel(DAO) then it asks for the server name,Login ID,database etc which is not applicable for the text file which i want to get converted into the crystal report...
I am not getting how to create the crystal report for a given text file....
Also how to disable the print & export options of the crystal report????

Waiting eagerly for positive response...


Regards,
Trupti



0
TPink
Asked:
TPink
2 Solutions
 
planoczCommented:
You have to use a ADO connection...

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.ReportSource
Imports CrystalDecisions.Shared
Imports ADODB                                 '<---- Access
Imports System.Data.SqlClient            '<---- SQL

    Public myReport As New ReportDocument        'Gobal Report Doc
    Public sAppPath = Application.StartupPath        'Application Directory Main Path
    Public sReportPath = "\Reports\"                     'Reports Directory Path


   '**** Server Connection Vars *********
    Public sDBServer As String = "MYSERVER"
    Public sUSERid As String = "MYUSER"
    Public sDBName As String = "MYDATABASE"
    Public sDBPass As String = ""
    Public Con As OleDb.OleDbConnection      '<--- for Access
    Public Connect As SqlConnection             '<--- for msSQL
    Public sSQL As String


    Private Sub GetReportConnection(ByVal myReport)
        ' Objects used to set the proper database connection information
        Dim tbCurrent As CrystalDecisions.CrystalReports.Engine.Table
        Dim tliCurrent As CrystalDecisions.Shared.TableLogOnInfo

        Try
            ' Load the report
            myReport.Load(sAppPath & sReportPath & sReportName, CrystalDecisions.[Shared].OpenReportMethod.OpenReportByTempCopy)
            ' Set the connection information for all the tables used in the report
            For Each tbCurrent In myReport.Database.Tables
                tliCurrent = tbCurrent.LogOnInfo
                With tliCurrent.ConnectionInfo
                    .ServerName = sDBServer
                    .UserID = sUSERid
                    .Password = ""
                    .DatabaseName = sDBName
                End With
                tbCurrent.ApplyLogOnInfo(tliCurrent)
            Next tbCurrent
        Catch Exp As LoadSaveReportException
            MsgBox("Incorrect path for loading report.", _
                    MsgBoxStyle.Critical, "Load Report Error")
        Catch Exp As Exception
            MsgBox(Exp.Message & "   in GetReportConnection Procedure", MsgBoxStyle.Critical, "General Error")
        End Try
    End Sub

0
 
mlmccCommented:
To completely disable printing and exporting
Printing
Open the report
Click FILE --> REPORT OPTIONS
Click the NO PRINTER option.  Report cannot be printed until this is turned off

Export
Don't load any of the Export dlls on the client machine

How do you plan to display the report?  Is it from a viewer or the Crystal designer?
What version of Crystal?  Which edition?

mlmcc
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now