Sai Ram

Sai Ram

  • NA
  • 237
  • 116.6k

Crystal Reports Database Logon Failed

Nov 14 2012 11:58 AM
Hi...I am getting Database Logon Failed in Crystal Reports using MS Access DB..
My Code is as follows

            Dim dt As New DataTable
            Dim da As New OleDbDataAdapter
        
            con = New OleDbConnection(clsConnection.GetConnectionString())
            If con.State = ConnectionState.Closed Or con.State = ConnectionState.Broken             Then
                con.Open()
            End If

            da.Fill(dt)
          
            If dt.Rows.Count <> 0 Then
             
                Dim rpt As New ReportDocument()
                Dim cwd As String = System.IO.Directory.GetCurrentDirectory()
                If cwd.EndsWith("\bin\Debug") Then
                    cwd = cwd.Replace("\bin\Debug", "\Reports\Bill.rpt")

                Else
                    cwd += "\Reports\Bill.rpt"

                End If
                rpt.Load(cwd)
                Dim comp As String = rpt.GetComponentName()

                rpt.SetDataSource(dt)
              
                Dim sinfo As SummaryInfo = rpt.SummaryInfo
                'sinfo.ReportTitle = sel_desc
                Dim frm1 As New Form()
                ' label3.Text = ""
                frm1.SetDesktopBounds(0, 0, 1024, 768)
                Dim crystalReportViewer1 As New                 CrystalDecisions.Windows.Forms.CrystalReportViewer()
                crystalReportViewer1.ShowGroupTreeButton = False

                crystalReportViewer1.ReportSource = rpt
                crystalReportViewer1.Dock = DockStyle.Fill
              
                rpt.SetDatabaseLogon("Administrator", "nokia", "Saibaba", "C:\Users\Administrator\Desktop\MedicalApplication\MedicalApplication\bin\Debug\Medical.mdb")
                crystalReportViewer1.Refresh()
                crystalReportViewer1.PrintReport()
                'frm1.Controls.Add(crystalReportViewer1)
                'frm1.MaximumSize = New System.Drawing.Size(1600, 1000)
                'frm1.Show()
                'frm1.Text = "Bill Printing"
            Else
                MessageBox.Show("Records Are Empty!", "Medical Application")
            End If