Search code examples
vb.netstringcrystal-reportsconnectionreport

VB.Net crystal report connection string


I am using vb.net 2010 to develop my software. Also have crystal reports in my projects and things are working perfectly in my PC.

My problem is that I design the crystal report in my PC with wizard and my PC is not the server, then upload it to the server so it would be accessible to users. But when try to open report a connection problem to the database pops up. I know that is due to the connection property when I designed the reports in my PC.

How can I solve this problem.


Solution

  • It is showing the popup for giving userid and password. I want to give the server connection programatically.

    enter image description here

    i given the following code still it showing the popup

    Private Sub CrystalReportViewer1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles CrystalReportViewer1.Load
            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
            cryRpt.Load("E:\ColorLab1\colorlab\colorlab\rpt_bill.rpt")
    
            With crConnectionInfo
                .ServerName = "MAHESH\SQLEXPRESS"
                .DatabaseName = "cc"
                .UserID = "erp"
                .Password = "123"
            End With
    
            CrTables = cryRpt.Database.Tables
            For Each CrTable In CrTables
                crtableLogoninfo = CrTable.LogOnInfo
                crtableLogoninfo.ConnectionInfo = crConnectionInfo
                CrTable.ApplyLogOnInfo(crtableLogoninfo)
            Next
            CrystalReportViewer1.RefreshReport()
        End Sub
    

    How can i solve this?