Ciao questo il codice, ora funziona, ma non mi è chiaro come funziona la relazione tra dataset e datatable
li avevo rinominati e non capivo come collegarli.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
ReportViewer1.ProcessingMode = ProcessingMode.Local
ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/stacertificato.rdlc")
Dim dsCustomers As DataSet1 = GetData("select * from certificati where CEcodsoc = '" & Session("parm_codsoc") & "' and CElotto = '" & parm & "'")
Dim datasource As New ReportDataSource("DataSet1", dsCustomers.Tables(0))
ReportViewer1.LocalReport.DataSources.Clear()
ReportViewer1.LocalReport.DataSources.Add(datasource)
End If
End Sub
Private Function GetData(query As String) As DataSet1
Dim conString As String = ConfigurationManager.ConnectionStrings("AroMidaConnectionString").ConnectionString
Dim cmd As New SqlCommand(query)
Using con As New SqlConnection(conString)
Using sda As New SqlDataAdapter()
cmd.Connection = con
sda.SelectCommand = cmd
Using dsCustomers As New DataSet1()
sda.Fill(dsCustomers, "DataTable1")
Return dsCustomers
End Using
End Using
End Using
End Function