Torna al Thread

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim strwhere As String = "" Dim sql As String If CBL_1.SelectedValueList.ToString <> "" Then strwhere = " AND (campo1 IN (" & CBL_1.SelectedValueList.ToString & "))" End If If CBL_2.SelectedValueList.ToString <> "" Then strwhere = strwhere & " AND (campo2 IN (" & CBL_2.SelectedValueList.ToString & "))" End If ... sql = " SELECT campo1,campo2... " & _ " FROM tabella " & _ " WHERE (1 = 1) " & strwhere lbl_sql.Text = sql Dim crystalReport As New ReportDocument() crystalReport.Load(Server.MapPath("~\Folder\nomereport.rpt")) Dim ds As DS_Catalogo = GetData(sql) crystalReport.SetDataSource(ds) CrystalReportViewer1.ReportSource = crystalReport CrystalReportViewer1.ID = "Catalogo_Disponibilita" If ds.Tables(0).Rows.Count = 0 Then lblmessage.Text = "Non ci sono dati con questi filtri !" Else lblmessage.Text = "" End If End Sub Private Function GetData(query As String) As DS_Catalogo Dim conString As String = ConfigurationManager.ConnectionStrings("ConnectionString").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 ds As New DS_Catalogo() sda.Fill(ds, "DataTable1") Return ds End Using End Using End Using End Function
Copyright © dotNetHell.it 2002-2025
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5