1 Replies - 12898 Views - Last Post: 15 October 2009 - 02:02 PM Rate Topic: -----

#1 rainmark  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 64
  • Joined: 21-August 09

DISPLAY THE SUM(FROM SQl COLUMN) TO A LABEL

Posted 15 October 2009 - 01:53 PM

what im trying to do is to disply the sum of the payments to a label
i still cant :(
please help me out

		Dim cmdTextName As String = "SELECT Payments FROM tblSubject WHERE StudentId = '" & CInt(cboName.SelectedValue) & "' "
		Dim sqlcmdName As New SqlCommand(cmdTextName, New SqlConnection(GetConnection))
		sqlcmdName.Connection.Open()
		Dim r As SqlDataReader = sqlcmdName.ExecuteReader()
		While r.Read
			lblTotalBill.Text = r("Sum(Payments)")
			r.Close()
		End While
		sqlcmdName.Connection.Close()


This post has been edited by rainmark: 15 October 2009 - 01:54 PM


Is This A Good Question/Topic? 1
  • +

Replies To: DISPLAY THE SUM(FROM SQl COLUMN) TO A LABEL

#2 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1726
  • View blog
  • Posts: 5,704
  • Joined: 25-September 09

Re: DISPLAY THE SUM(FROM SQl COLUMN) TO A LABEL

Posted 15 October 2009 - 02:02 PM

"SELECT Sum(Payments) as ttlPay FROM tblSubject ...

Then your label.text would be = r("ttlPay")
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1