0% found this document useful (0 votes)
34 views

Crystal Report Code

The document provides instructions to customize a Crystal Report for a student database table. It specifies to save the Crystal Report file as CrystalReport1, use the Student table, and update the data source name, SQL server instance, database name, username, and password according to the user's local configuration. It also includes code to populate the CrystalReportViewer control by executing a SQL query to retrieve all records from the Student table, loading the results into a DataSet, setting this as the report data source, and assigning the report to the viewer.

Uploaded by

Aamir Ch
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

Crystal Report Code

The document provides instructions to customize a Crystal Report for a student database table. It specifies to save the Crystal Report file as CrystalReport1, use the Student table, and update the data source name, SQL server instance, database name, username, and password according to the user's local configuration. It also includes code to populate the CrystalReportViewer control by executing a SQL query to retrieve all records from the Student table, loading the results into a DataSet, setting this as the report data source, and assigning the report to the viewer.

Uploaded by

Aamir Ch
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Changes required accordingly

1. Save Crystal Report Name: CrystalReport1


2. Save Table Name: Student
3. Change Data source OR mycon path and user password according to your own

Code to Populate the Report


Imports System
Imports System.Data
Imports System.Data.SqlClient

Public Class Form1

Private Sub Form1_Load(sender As Object, e As EventArgs)


Handles MyBase.Load

Dim rpt As New CrystalReport1


Dim myCon As SqlConnection
Dim myAdapter As SqlDataAdapter
Dim myDataset As New DataSet

myCon = New SqlConnection("Data Source=RAZA\SQLEXPRESS;Initial


Catalog=testdb;User ID=sa;Password=raza")

myAdapter = New SqlDataAdapter("SELECT * FROM Student", myCon)


myAdapter.Fill(myDataset, "Student")
rpt.SetDataSource(myDataset)
CrystalReportViewer1.ReportSource = rpt

End Sub

End Class

You might also like