Bind Crystal Report in ASP.Net
This code sample shows how to bind a crystal report in asp.net
Dim myConnection As New SqlClient.SqlConnection()
myConnection.ConnectionString = "server= (local)\NetSDK;database=pubs;Trusted_Connection=yes"
Dim MyCommand As New SqlClient.SqlCommand()
MyCommand.Connection = myConnection
MyCommand.CommandText = "Select * from Stores"
MyCommand.CommandType = CommandType.Text
Dim MyDA As New SqlClient.SqlDataAdapter()
MyDA.SelectCommand = MyCommand
Dim myDS As New Dataset1()
'This is our DataSet created at Design Time
MyDA.Fill(myDS, "Stores")
'You have to use the same name as that of your Dataset that you created during design time
Dim oRpt As New CrystalReport1()
' This is the Crystal Report file created at Design Time
oRpt.SetDataSource(myDS)
' Set the SetDataSource property of the Report to the Dataset
CrystalReportViewer1.ReportSource = oRpt
Dim myConnection As New SqlClient.SqlConnection()
myConnection.ConnectionString = "server= (local)\NetSDK;database=pubs;Trusted_Connection=yes"
Dim MyCommand As New SqlClient.SqlCommand()
MyCommand.Connection = myConnection
MyCommand.CommandText = "Select * from Stores"
MyCommand.CommandType = CommandType.Text
Dim MyDA As New SqlClient.SqlDataAdapter()
MyDA.SelectCommand = MyCommand
Dim myDS As New Dataset1()
'This is our DataSet created at Design Time
MyDA.Fill(myDS, "Stores")
'You have to use the same name as that of your Dataset that you created during design time
Dim oRpt As New CrystalReport1()
' This is the Crystal Report file created at Design Time
oRpt.SetDataSource(myDS)
' Set the SetDataSource property of the Report to the Dataset
CrystalReportViewer1.ReportSource = oRpt
Labels: Crystal Reports

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home