on 10-04-2014 11:30 PM
Hi Everyone,
I'm trying to integrate my existing crystal report into VB.Net. When I try to call the crystal report from my program, CR pops up a database login screen. After entering sa login and password, I get attached logon failed error. Can somebody please help me resolve this? My CR is very complicated and has 8 subreports to it.
Thanks,
Amol
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What version of CR? What CR Service Pack.
What database?
How are you connecting to the database?
Does the report work anywhere? In CR designer?
What version of .NET?
- Ludek
Senior Support Engineer AGS Product Support, Global Support Center Canada
Follow us on Twitter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ludek,
Below is the answer to your questions:
What version of CR? What CR Service Pack.
CrystalReports for Visual 2010.
What database?
Microsoft SQL Server 2008 R2.
How are you connecting to the database?
Dim rptdocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument
rptdocument.Load(strreportpath)
rptdocument.SetDatabaseLogon("sa", "test123")
rptdocument.SetDataSource(sqlds.Tables(0))
CrystalReportViewer1.ReportSource = rptdocument
CrystalReportViewer1.Refresh()
Does the report work anywhere? In CR designer?
Yes, the report works perfect in CR designer
What version of .NET?
Microsoft Visual Studio 2010
Version 10.0.40219.1 SP1Rel
I hope that helps. Thanks.
Regards,
Amol
Hi Amol,
What Crystal service pack are you using?
Also, search, lots of post on the DB driver you should be using for that SQL Server.
And don't call refresh, that virtually reloads the reports default properties and therefore ignores your log on info.
You also have to set the log on info for each subreport, search, lots of samples on how to get the subreport objects and then set the log on info.
Don
Ok. I still do not know the CR Service pack you are using. So, go here and download SP 11.
For MS SQL Server 2008, make sure you are using SQL Native 10 or higher client.
For code, download the Developer Help file:
SAP Crystal Reports .NET SDK Developer Guide
Search for 'connect'. You will get a lot of help on best code. You can also look at sample apps here:
Crystal Reports for .NET SDK Samples - Business Intelligence (BusinessObjects) - SCN Wiki
Samples csharp_win_dbengine.zip / vb_win_dbengine.zip
- Ludek
Senior Support Engineer AGS Product Support, Global Support Center Canada
Follow us on Twitter
Hi Ludek,
As suggested, I've installed SP 11 on my machine.
Don,
I also got rid of CrystalReportViewer1.Refresh() from my code. Can you please give me hand on setting up dblogon for the subreports? Below is my code:
Thanks,
Amol
Imports CrystalDecisions.Shared
Imports CrystalDecisions.CrystalReports.Engine
Imports System.Data.SqlClient
Public Class Form2
Private Sub CrystalReportViewer1_Load(sender As System.Object, e As System.EventArgs) Handles CrystalReportViewer1.Load
Try
strsql = "select * from JobHeader where Jobnumber='J004295'"
Dim sqlda As New SqlDataAdapter(strsql, sqlconn)
sqlda.Fill(sqlds, "table1")
strreportname = "Report1"
Dim strreportpath As String = Application.StartupPath & "\" & strreportname & ".rpt"
If Not IO.File.Exists(strreportpath) Then
Throw (New Exception("unable to locate report file: " & vbCrLf & strreportpath))
End If
Dim rptdocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument
rptdocument.Load(strreportpath)
rptdocument.SetDatabaseLogon("sa", "test123")
rptdocument.SetDataSource(sqlds.Tables(0))
CrystalReportViewer1.ReportSource = rptdocument
'CrystalReportViewer1.Refresh()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub Form2_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
User | Count |
---|---|
81 | |
25 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.