สร้างรายงานด้วย Microsoft Report พอรันแล้วขึ้น Error :
An error has occurred during report processing. A data source instance has not been supplied for the data source "myDs_dtDMHT". = ชื่อ Dataset กับ DataAdapter ถูกต้อง แต่ไม่รู้ว่าโค้ดถูกรึเปล่า
Code (VB.NET)
Imports System.Data
Imports CrystalDecisions.CrystalReports.Engine
Imports Microsoft.Reporting.WebForms
Imports System.IO
Imports MySql.Data.MySqlClient
Imports MySql.Data
Imports System.Data.Odbc
Imports System.Web.UI
Partial Class landReport
Inherits System.Web.UI.Page
Dim objConn As New MySqlConnection
Dim objCmd As New MySqlCommand
Dim dtAdapter As New MySqlDataAdapter
Dim ds As New DataSet
Dim dt As DataTable
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
objConn.ConnectionString = clsVariable.strConn
With objCmd
.Connection = objConn
.CommandText = clsVariable.strSql
.CommandType = CommandType.Text
End With
dtAdapter.SelectCommand = objCmd
dtAdapter.Fill(ds)
dt = ds.Tables(0)
dtAdapter = Nothing
objConn.Close()
objConn = Nothing
If clsVariable.lcPrint = "chrReg" Then
ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("myDS_dtDMHT", dt))
Else
ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("myDS_DataTable1", dt))
End If
Select Case clsVariable.lcPrint
Case "opdDiag"
ReportViewer1.LocalReport.ReportPath = "rptOpdDiag.rdlc"
Case "ipdDiag"
ReportViewer1.LocalReport.ReportPath = "rptIpdDiag.rdlc"
Case "chrReg"
ReportViewer1.LocalReport.ReportPath = "rptRgt.rdlc"
End Select
ReportViewer1.LocalReport.Refresh()
End Sub
End Class