简体   繁体   English

vb.net中尚未为数据源数据集1提供数据源实例

[英]data source instance has not been supplied for the data source dataset1 in vb.net

I have a problem with MySql and reports in vb.net. 我的MySql和vb.net中的报告有问题。 I have already installed MySql ODBC and my project is already connected to the database. 我已经安装了MySql ODBC,并且我的项目已经连接到数据库。 But I receive this error "data source instance has not been supplied for the data source dataset1". 但是我收到此错误“尚未为数据源数据集1提供数据源实例”。

I'm new with vb.net reports and any help will be appreciated. 我是vb.net报告的新手,我们将不胜感激。 Thank you.Attached to this is my code for loading my data. 谢谢。这是我用于加载数据的代码。

 If con.State = ConnectionState.Open Then

        Dim ds As New DataSet1
        Dim com As New MySqlCommand("select * from tb_course", con)
        Using da As New MySqlDataAdapter(com)
            da.Fill(ds)
        End Using 

        ReportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local

        ReportViewer1.LocalReport.ReportPath = System.Environment.CurrentDirectory + "\Report1.rdlc"

        ReportViewer1.LocalReport.DataSources.Clear()
        ReportViewer1.LocalReport.DataSources.Add(New Microsoft.Reporting.WinForms.ReportDataSource("DataSet1_DataTable1", ds.Tables(0)))

        ReportViewer1.DocumentMapCollapsed = True

        Me.ReportViewer1.RefreshReport()

    End If

You need to give the dataset name and table name 您需要提供数据集名称和表名称

I am going to give you code which is work on my Machine Correctly 我要给你的代码可以在我的机器上正常工作

Dim ds As New DataSet
    Dim dt As New DataTable
    Dim RpDs1 As New Microsoft.Reporting.WinForms.ReportDataSource
    Dim SQL As String = "select * from mfcount"
    Dim da As New OleDbDataAdapter(SQL, My.Settings.trialConnectionString)
    da.Fill(ds, "mfcount")
    dt = ds.Tables(0)
    ReportViewer1.Reset()
    ReportViewer1.LocalReport.DataSources.Clear()
    RpDs1.Name = "trialDataSet4_MFCount"
    RpDs1.Value = dt
    ReportViewer1.ProcessingMode = WinForms.ProcessingMode.Local
    ReportViewer1.LocalReport.DataSources.Add(RpDs1)
    Dim path = New DirectoryInfo(Application.StartupPath).Parent.Parent.Parent.FullName
    ReportViewer1.LocalReport.ReportEmbeddedResource = Application.StartupPath & "\Report\" & "ADDRESSReport.rdlc"
    ReportViewer1.LocalReport.ReportPath = Application.StartupPath & "\Report\" & "ADDRESSReport.rdlc"
    ReportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.PageWidth
    ReportViewer1.RefreshReport()

This code will help you.. 该代码将为您提供帮助。

thanks basuraj kumbhar for your help to solve this problem. 感谢basuraj kumbhar为您解决此问题提供的帮助。 Here is the working codes for MyCql connection Report in vb.net 这是vb.net中MyCql连接报告的工作代码

Dim ds As New DataSet
    Dim dt As New DataTable
    Dim RpDs1 As New Microsoft.Reporting.WinForms.ReportDataSource
    Dim SQL As String = "select * from tb_course"
    Dim da As New MySqlDataAdapter(SQL, con)

    da.Fill(ds, "tb_course")
    dt = ds.Tables(0)
    ReportViewer1.Reset()
    ReportViewer1.LocalReport.DataSources.Clear()
    RpDs1.Name = "DataSet1"
    RpDs1.Value = dt
    ReportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local

    ReportViewer1.LocalReport.ReportPath = System.Environment.CurrentDirectory + "\Report1.rdlc"
    ReportViewer1.LocalReport.DataSources.Clear()
    ReportViewer1.LocalReport.DataSources.Add(New Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", ds.Tables(0)))

    ReportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.PageWidth
    ReportViewer1.RefreshReport()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM