Click here to Skip to main content
15,902,275 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: File I/O - Use a data table ? Pin
barney_197219-Sep-07 3:53
barney_197219-Sep-07 3:53 
QuestionHow to disable the Predefined TextBox Properties Pin
VB 8.019-Sep-07 1:52
VB 8.019-Sep-07 1:52 
Question.GIF file in status bar Pin
ejaz_pk19-Sep-07 1:22
ejaz_pk19-Sep-07 1:22 
AnswerRe: .GIF file in status bar Pin
Guffa19-Sep-07 3:20
Guffa19-Sep-07 3:20 
QuestionlybraVb.dll Pin
Faruzzy19-Sep-07 1:00
Faruzzy19-Sep-07 1:00 
AnswerRe: lybraVb.dll Pin
Dave Kreskowiak19-Sep-07 2:23
mveDave Kreskowiak19-Sep-07 2:23 
QuestionDynamic loading data in crystal report Pin
Mekong River18-Sep-07 23:54
Mekong River18-Sep-07 23:54 
AnswerRe: Dynamic loading data in crystal report Pin
JamesS[C1]25-Sep-07 2:17
JamesS[C1]25-Sep-07 2:17 
Hello,

To include the report on the Web page, we need to drag and drop the Crystal Report Viewer control from the Toolbox. Because the Crystal Report Viewer control doesn't have a ReportSource property available at design time, you have to set that property inside your code.

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents CrystalReportViewer1 As CrystalDecisions.Web.CrystalReportViewer
#Region " Windows Form Designer generated code "

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
CrystalReportViewer1.ReportSource = Server.MapPath("crystalreport1.rpt")
End Sub

End Class.

or you can create instance of the report class which was created by Visual Studio.NET when you designed your report. The name of that file is same as report that you create CrystalReport1.vb. To see this file expand CrystalReport1.rpt (click on + sign in front of the CrystalReport1.rpt).

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents CrystalReportViewer1 As CrystalDecisions.Web.CrystalReportViewer
#Region " Windows Form Designer generated code "

Dim crpt As CrystalReport1
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
crpt = New CrystalReport1()
CrystalReportViewer1.ReportSource = crpt
End Sub

End Class.

If you set WebForm1.aspx to be the Start Up page for the project, and start the project, you will get the report page if you have blank password in database for "sa". If "sa" or any other user name that you want to use to access database has password, when you run the report, you will see the "LogonFailed" error. If we were developing windows application, Crystal Reports will ask us for password information. This error occured, because when you design and save report, all of the connection information is saved within the report except password. If the password is blank, there will be no problem to create or generate the report.

To prevent this, you will need to provide login information in your code before you set ReportSource property. To do so, you will add some code in Page_Load event. Now, your code should look like:

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents CrystalReportViewer1 As CrystalDecisions.Web.CrystalReportViewer
#Region " Windows Form Designer generated code "

Dim crpt As CrystalReport1
Dim myTable As CrystalDecisions.CrystalReports.Engine.Table
Dim myLogin As CrystalDecisions.Shared.TableLogOnInfo
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
crpt = New CrystalReport1()

For Each myTable In crpt.Database.Tables
myLogin = myTable.LogOnInfo
myLogin.ConnectionInfo.Password = "test"
myLogin.ConnectionInfo.UserID = "sa"
myTable.ApplyLogOnInfo(myLogin)
Next

CrystalReportViewer1.ReportSource = crpt
End Sub

End Class.

Now, if you run the report, you will not get an error page and evrything will look OK. The report will be generated and shown in your Web page.

Regards,
James

James Smith
www.componentone.com

QuestionRemoving tables with multiple columns froma aword file [modified] Pin
Prakash_Mishra18-Sep-07 23:48
Prakash_Mishra18-Sep-07 23:48 
QuestionCrystal Report In VB Pin
syibu18-Sep-07 23:47
syibu18-Sep-07 23:47 
AnswerRe: Crystal Report In VB Pin
JamesS[C1]19-Sep-07 3:59
JamesS[C1]19-Sep-07 3:59 
QuestionNeed of code to get used memory space and free memory space in a harddisk.. Pin
Balagurunathan S18-Sep-07 23:17
Balagurunathan S18-Sep-07 23:17 
AnswerRe: Need of code to get used memory space and free memory space in a harddisk.. Pin
Tom Deketelaere19-Sep-07 1:18
professionalTom Deketelaere19-Sep-07 1:18 
Questionreplacing single instance of a substring in a string Pin
Mustafa Ismail Mustafa18-Sep-07 22:01
Mustafa Ismail Mustafa18-Sep-07 22:01 
AnswerRe: replacing single instance of a substring in a string Pin
Mustafa Ismail Mustafa18-Sep-07 22:13
Mustafa Ismail Mustafa18-Sep-07 22:13 
Questiondeploying application. Pin
d_smit18-Sep-07 21:36
d_smit18-Sep-07 21:36 
AnswerRe: deploying application. Pin
GuyThiebaut19-Sep-07 0:18
professionalGuyThiebaut19-Sep-07 0:18 
GeneralRe: deploying application. Pin
d_smit19-Sep-07 2:56
d_smit19-Sep-07 2:56 
GeneralRe: deploying application. Pin
JamesS[C1]20-Sep-07 3:20
JamesS[C1]20-Sep-07 3:20 
Questioncode to print Pin
Faruzzy18-Sep-07 20:40
Faruzzy18-Sep-07 20:40 
AnswerRe: code to print Pin
C1AllenS18-Sep-07 22:27
C1AllenS18-Sep-07 22:27 
QuestionHoverGradientButton Lybra.Forms.controls.Hovergradient Pin
Faruzzy18-Sep-07 20:37
Faruzzy18-Sep-07 20:37 
AnswerRe: HoverGradientButton Lybra.Forms.controls.Hovergradient [modified] Pin
Dave Kreskowiak19-Sep-07 2:03
mveDave Kreskowiak19-Sep-07 2:03 
QuestionSharing window folder Pin
helelark12318-Sep-07 19:36
helelark12318-Sep-07 19:36 
AnswerRe: Sharing window folder Pin
Dave Kreskowiak19-Sep-07 2:01
mveDave Kreskowiak19-Sep-07 2:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.