I summed a column of numbers and would like to put them in a Label field to display the result. I understand the conversion for number to string, I don't understand how to that value, that has been summed, to do it.
thanks
grady
int x = 7;
int y = 7;
int z = x + y;
LabelID.Text = z.ToString();
Is that what you're looking for?
HTH,
Ryan
Actually I have summed a column called TFsum and I was trying to display that and it say it was undeclared.
Here is the SQL:
SELECT SUM(filesfailed) AS TFsum
FROM accmonreport
WHERE oa='ddlOA'
HAVING SUM(filesfailed)=0
ddlOA is a dropdown list in the first view on the page. I'm just to get the variable TFsum to do some calculations.
thanks
grady
Could you post the relevent code?
Ryan
All I'm trying now is get the TFsum value into the lblcompliant label.
thanks
grady
Imports System.Data
Imports System.Data.OleDB
Imports System.Data.OleDb.OleDbDataReader
Partial Class reports_508report
Inherits System.Web.UI.Page
Protected Sub SubmitBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
If (Page.IsValid) Then
Dim ddlOA As String = ddloalist.SelectedValue
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
"c:\accmon\database\accmon.mdb" & ";"
Dim MySQL As String = "SELECT SUM(filesfailed)AS TFsum FROM accmonreport WHERE oa='ddlOA' HAVING filesfailed=0"
Dim MyConn As New OleDbConnection(strConn)
Dim cmd As New OleDbCommand(MySQL, MyConn)
MyConn.Open()
cmd.ExecuteReader()
MyConn.Close()
lblCompliant.Text = " "
OAReport.SetActiveView(Result)
End If
End Sub
End Class
You need to make a couple of changes.
If (Page.IsValid) Then
Dim ddlOA As String = ddloalist.SelectedValue
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
"c:\accmon\database\accmon.mdb" & ";"
Dim MySQL As String = "SELECT SUM(filesfailed)AS TFsum FROM accmonreport WHERE oa='" & ddlOA & "' HAVING filesfailed=0"
Dim reader As OleDbDataReader
Dim MyConn As New OleDbConnection(strConn)
Dim cmd As New OleDbCommand(MySQL, MyConn)
MyConn.Open()
reader =cmd.ExecuteReader()
While reader.Read()
lblCompliant.Text = reader("TFsum")
End While
reader.Close()
MyConn.Close()
OAReport.SetActiveView(Result)
End If
HTH,
Ryan
Thanks, I really appreciate your time and knowledge. If you don't mind, I have one more question. In Coldfusion there is a function that gives me a recordcount after every query. How do you implement something like that in .Net?
thanks
grady
0 comments:
Post a Comment