Hi Dedzil,
Dedzil says:
crystalReport.SetDataSource(StudentInfo)
Specified DataTable Name.
Please refer below sample.
HTML
Default
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<style type="text/css">
.auto-style1 { width: 100%; float: left; border: 1px solid #000000; }
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true" />
</asp:Content>
Master
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
Namespaces
VB.Net
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports CrystalDecisions.CrystalReports.Engine
Code
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Me.BindCrystalReport()
End Sub
Private Sub BindCrystalReport()
Dim crystalReport As ReportDocument = New ReportDocument()
crystalReport.Load(Server.MapPath("~/CrystalReport.rpt"))
Dim dsStudent As DataSet1 = GetData("SELECT StudentID,City,Country FROM Students")
crystalReport.SetDataSource(dsStudent.Tables("DataTable1"))
CrystalReportViewer1.ReportSource = crystalReport
End Sub
Private Function GetData(ByVal query As String) As DataSet1
Dim conString As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
Using con As SqlConnection = New SqlConnection(conString)
Using cmd As SqlCommand = New SqlCommand(query)
Using sda As SqlDataAdapter = New SqlDataAdapter(cmd)
cmd.Connection = con
Using dsStudent As DataSet1 = New DataSet1()
sda.Fill(dsStudent, "DataTable1")
Return dsStudent
End Using
End Using
End Using
End Using
End Function
Screenshot