Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How do I fix this final error about object instance
Message
Information générale
Forum:
ASP.NET
Catégorie:
Rapports
Divers
Thread ID:
01031240
Message ID:
01574195
Vues:
59
I am using code like the following to view Crystal Reports from .Net
Public Class Form1
    
    Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        Dim oApp = New CRAXDRT.Application
        Dim oReport As CRAXDRT.Report
        oReport = oApp.OpenReport("C:\temp\DR3076.R01.rpt", 1)

        With oReport.Database.Tables(1).ConnectionProperties
            .DeleteAll()
            .Add("Provider", "SQLOLEDB.1")
            .Add("User ID", "UserName")
            .Add("Password", "Password")
            .Add("Initial Catalog", "Database")
            .Add("DSN", "DSNName")

        End With

        AxCrystalActiveXReportViewer1.ReportSource = oReport
        AxCrystalActiveXReportViewer1.ViewReport()
>Thanks ahead of time. I will keep trying to figure this out while you lend me a hand. THANKS!
>
>What's the code look like to logon to a VPN where it asks me to supply a User name and Password so when I run the VB.NET application below which in turns runs a Crystal Report it will not give me the error:
>Logon failed.
>
>It's probably only one or two lines of code that I need.
>
>
>Public Class Form4
>    Inherits System.Windows.Forms.Form
>
>#Region " Windows Form Designer generated code "
>
>    Public Sub New()
>        MyBase.New()
>
>        'This call is required by the Windows Form Designer.
>        InitializeComponent()
>
>        'Add any initialization after the InitializeComponent() call
>
>    End Sub
>
>    'Form overrides dispose to clean up the component list.
>    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
>        If disposing Then
>            If Not (components Is Nothing) Then
>                components.Dispose()
>            End If
>        End If
>        MyBase.Dispose(disposing)
>    End Sub
>
>    'Required by the Windows Form Designer
>    Private components As System.ComponentModel.IContainer
>
>    'NOTE: The following procedure is required by the Windows Form Designer
>    'It can be modified using the Windows Form Designer.  
>    'Do not modify it using the code editor.
>    Friend WithEvents Button2 As System.Windows.Forms.Button
>    Friend WithEvents Button1 As System.Windows.Forms.Button
>    Friend crViewer As CrystalActiveXReportViewerLib11.CrystalActiveXReportViewerClass
>    Friend WithEvents AxCrystalActiveXReportViewer1 As AxCrystalActiveXReportViewerLib11.AxCrystalActiveXReportViewer
>    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
>        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form4))
>        Me.Button2 = New System.Windows.Forms.Button
>        Me.Button1 = New System.Windows.Forms.Button
>        Me.AxCrystalActiveXReportViewer1 = New AxCrystalActiveXReportViewerLib11.AxCrystalActiveXReportViewer
>        CType(Me.AxCrystalActiveXReportViewer1, System.ComponentModel.ISupportInitialize).BeginInit()
>        Me.SuspendLayout()
>        '
>        'Button2
>        '
>        Me.Button2.Location = New System.Drawing.Point(415, 576)
>        Me.Button2.Name = "Button2"
>        Me.Button2.TabIndex = 7
>        Me.Button2.Text = "Continue"
>        '
>        'Button1
>        '
>        Me.Button1.Location = New System.Drawing.Point(503, 576)
>        Me.Button1.Name = "Button1"
>        Me.Button1.TabIndex = 8
>        Me.Button1.Text = "Cancel"
>        '
>        'AxCrystalActiveXReportViewer1
>        '
>        Me.AxCrystalActiveXReportViewer1.Enabled = True
>        Me.AxCrystalActiveXReportViewer1.Location = New System.Drawing.Point(16, 16)
>        Me.AxCrystalActiveXReportViewer1.Name = "AxCrystalActiveXReportViewer1"
>        Me.AxCrystalActiveXReportViewer1.OcxState = CType(resources.GetObject("AxCrystalActiveXReportViewer1.OcxState"), System.Windows.Forms.AxHost.State)
>        Me.AxCrystalActiveXReportViewer1.Size = New System.Drawing.Size(960, 544)
>        Me.AxCrystalActiveXReportViewer1.TabIndex = 9
>        '
>        'Form4
>        '
>        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
>        Me.ClientSize = New System.Drawing.Size(992, 614)
>        Me.Controls.Add(Me.AxCrystalActiveXReportViewer1)
>        Me.Controls.Add(Me.Button1)
>        Me.Controls.Add(Me.Button2)
>        Me.Name = "Form4"
>        Me.Text = "BayForce Technology Solutions"
>        CType(Me.AxCrystalActiveXReportViewer1, System.ComponentModel.ISupportInitialize).EndInit()
>        Me.ResumeLayout(False)
>
>    End Sub
>
>#End Region
>    Dim crxApplication As New CRAXDRT.Application
>    Public oReport As CRAXDRT.Report
>    Public cboRpt1, cboRpt2 As String
>    Public start_date, end_date As String
>
>    Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
>
>        If cboRpt1 = 0 And cboRpt2 = 0 Then
>            oReport = crxApplication.OpenReport("C:\Documents and Settings\BayForce\My Documents\Crystal Reports\emsub.rpt", 1)
>            oReport.ParameterFields.Item(1).AddCurrentValue(CDate(F1.TextBox2.Text))
>            oReport.ParameterFields.Item(2).AddCurrentValue(CDate(F1.TextBox3.Text))
>        ElseIf cboRpt1 = 0 And cboRpt2 = 1 Then
>            oReport = crxApplication.OpenReport("C:\Documents and Settings\BayForce\My Documents\Crystal Reports\emsub.rpt", 1)
>            oReport.ParameterFields.Item(1).AddCurrentValue(CDate(F1.TextBox2.Text))
>            oReport.ParameterFields.Item(2).AddCurrentValue(CDate(F1.TextBox3.Text))
>        ElseIf cboRpt1 = 0 And cboRpt2 = 2 Then
>            oReport = crxApplication.OpenReport("C:\Documents and Settings\BayForce\My Documents\Crystal Reports\emsub.rpt", 1)
>            oReport.ParameterFields.Item(1).AddCurrentValue(CDate(F1.TextBox2.Text))
>            oReport.ParameterFields.Item(2).AddCurrentValue(CDate(F1.TextBox3.Text))
>        ElseIf cboRpt1 = 1 And cboRpt2 = 0 Then
>            oReport = crxApplication.OpenReport("C:\Documents and Settings\BayForce\My Documents\Crystal Reports\emsub.rpt", 1)
>        ElseIf cboRpt1 = 1 And cboRpt2 = 1 Then
>            oReport = crxApplication.OpenReport("C:\Documents and Settings\BayForce\My Documents\Crystal Reports\emsub.rpt", 1)
>        ElseIf cboRpt1 = 1 And cboRpt2 = 2 Then
>            oReport = crxApplication.OpenReport("C:\Documents and Settings\BayForce\My Documents\Crystal Reports\emsub.rpt", 1)
>        ElseIf cboRpt1 = 1 And cboRpt2 = 3 Then
>            oReport = crxApplication.OpenReport("C:\Documents and Settings\BayForce\My Documents\Crystal Reports\emsub.rpt", 1)
>            oReport.ParameterFields.Item(1).AddCurrentValue(CDate(F1.TextBox2.Text))
>            oReport.ParameterFields.Item(2).AddCurrentValue(CDate(F1.TextBox3.Text))
>        ElseIf cboRpt1 = 1 And cboRpt2 = 4 Then
>            oReport = crxApplication.OpenReport("C:\Documents and Settings\BayForce\My Documents\Crystal Reports\emsub.rpt", 1)
>            oReport.ParameterFields.Item(1).AddCurrentValue(CDate(F1.TextBox2.Text))
>            oReport.ParameterFields.Item(2).AddCurrentValue(CDate(F1.TextBox3.Text))
>        ElseIf cboRpt1 = 2 And cboRpt2 = 0 Then
>            oReport = crxApplication.OpenReport("C:\Documents and Settings\BayForce\My Documents\Crystal Reports\emsub.rpt", 1)
>        ElseIf cboRpt1 = 2 And cboRpt2 = 1 Then
>            oReport = crxApplication.OpenReport("C:\Documents and Settings\BayForce\My Documents\Crystal Reports\emsub.rpt", 1)
>        ElseIf cboRpt1 = 2 And cboRpt2 = 2 Then
>            oReport = crxApplication.OpenReport("C:\Documents and Settings\BayForce\My Documents\Crystal Reports\emsub.rpt", 1)
>        ElseIf cboRpt1 = 2 And cboRpt2 = 3 Then
>            oReport = crxApplication.OpenReport("C:\Documents and Settings\BayForce\My Documents\Crystal Reports\emsub.rpt", 1)
>        ElseIf cboRpt1 = 2 And cboRpt2 = 4 Then
>            oReport = crxApplication.OpenReport("C:\Documents and Settings\BayForce\My Documents\Crystal Reports\emsub.rpt", 1)
>        ElseIf cboRpt1 = 2 And cboRpt2 = 5 Then
>            oReport = crxApplication.OpenReport("C:\Documents and Settings\BayForce\My Documents\Crystal Reports\emsub.rpt", 1)
>        End If
>
>        crViewer.ReportSource = oReport
>        crViewer.ViewReport()
>    End Sub
>
>    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
>        Me.Hide()
>        F1.Show()
>    End Sub
>
>    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
>        Me.Hide()
>    End Sub
>End Class
>
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform