Torna al Thread

Dim strSQL As String Dim strSQLTOT As String Dim ds As New DataSet Dim da As New SqlDataAdapter Dim cmd As New SqlCommand Dim con As New SqlConnection(strConnectionString) strSQLTOT = "SELECT SUM(Imponibile * (1+IVA)) AS TOTALE From Fatture" strSQL = "SELECT Imponibile, IVA, (Imponibile * (1+IVA)) AS TOTALE From Fatture ORDER BY DataFattura DESC" With cmd .Connection = con .CommandText = strSQL End With If con.State = ConnectionState.Closed Then con.Open() da.SelectCommand = cmd da.Fill(ds, "Fatture") dGrid1.DataSource = ds.Tables("Fatture") 'Estraggo il Totale CUMULATO delle Fatture (comprensive di IVA) e lo inserisco nella TextBox Dim aCmd As New SqlCommand(strSQLTOT, con) Dim da As New SqlDataAdapter(aCmd) Dim ds As New Data.DataSet da.Fill(ds,"Totale Fatture") If ds.Tables("Totale Fatture").Rows.Count = 0 Then totale.Text = "0" ElseIf IsDBNull(ds.Tables("Totale Fatture").Rows(0)(0)) Then totale.Text = "0" Else totale.Text = ds.Tables("Totale Fatture").Rows(0)(0) End If
Copyright © dotNetHell.it 2002-2025
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5