Click here to Skip to main content
15,891,981 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello friends i have designed a crystal report viewer i have designed the complete code and reports.i am pasting this code below.while running the program all the things work fine but even after passing the log in information for crystal report it's not working.please help needed
VB.NET
Imports Crystaldecisions.crystalreports.engine
Imports Crystaldecisions.reportsource
Imports Crystaldecisions.shared
Imports Crystaldecisions.windows.forms

Public Class Form5
    Dim cryRpt As New ReportDocument
    Dim crtableLogoninfos As New TableLogOnInfos
    Dim crtableLogoninfo As New TableLogOnInfo
    Dim crConnectionInfo As New ConnectionInfo
    Dim CrTables As Tables
    Dim CrTable As Table
    Dim doc As New ReportDocument
    Dim paramFields As New CrystalDecisions.Shared.ParameterFields()

    Dim paramField As New CrystalDecisions.Shared.ParameterField()
    Dim discreteVal As New CrystalDecisions.Shared.ParameterDiscreteValue()

    Dim paramField1 As New CrystalDecisions.Shared.ParameterField()
    Dim discreteVal1 As New CrystalDecisions.Shared.ParameterDiscreteValue()

    Dim paramField2 As New CrystalDecisions.Shared.ParameterField()
    Dim discreteVal2 As New CrystalDecisions.Shared.ParameterDiscreteValue()
    Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub CrystalReportViewer1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CrystalReportViewer1.Load
        cryRpt.Load("C:\sachin\hrreports\hrreports\Leave_bal130912.rpt")
        cryRpt.SetDatabaseLogon("sa", "admin-123")


        paramField.ParameterFieldName = "Year"
        discreteVal.Value = Form4.ComboBox1.SelectedText
        paramField.CurrentValues.Add(discreteVal)
        paramFields.Add(paramField)
        CrystalReportViewer1.ParameterFieldInfo = paramFields

        paramField1.ParameterFieldName = "Branch"
        discreteVal1.Value = Form4.ComboBox2.SelectedText
        paramField1.CurrentValues.Add(discreteVal1)
        paramFields.Add(paramField1)
        CrystalReportViewer1.ParameterFieldInfo = paramFields

        paramField2.ParameterFieldName = "Month"
        discreteVal2.Value = Form4.ComboBox3.SelectedText
        paramField2.CurrentValues.Add(discreteVal2)
        paramFields.Add(paramField2)
        CrystalReportViewer1.ParameterFieldInfo = paramFields

      

        CrystalReportViewer1.ParameterFieldInfo = paramFields
        CrystalReportViewer1.ParameterFieldInfo = paramFields
        CrystalReportViewer1.ParameterFieldInfo = paramFields


        With crConnectionInfo
            .IntegratedSecurity = True
            .ServerName = "testvm"
            .DatabaseName = "unizimhr"
            .UserID = "sa"
            .Password = "admin-123"
        End With


        CrTables = cryRpt.Database.Tables
        For Each CrTable In CrTables
            crtableLogoninfo = CrTable.LogOnInfo
            crtableLogoninfo.ConnectionInfo = crConnectionInfo
            CrTable.ApplyLogOnInfo(crtableLogoninfo)
        Next
        CrystalReportViewer1.ReportSource = cryRpt
        CrystalReportViewer1.Refresh()
    End Sub
End Class
Posted
Updated 1-Jul-13 2:28am
v2

1 solution

Hi,
What is the error message showing? Please try by removing the code
CrystalReportViewer1.Refresh()
 
Share this answer
 
v2
Comments
sachin bhise 3-Jul-13 6:50am    
Reji Ab: its not logging in the database

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900