0

I'm trying to calculate a column from a database called rogaine.mdb.
I've been using an SQL statement to do this as I only want to calculate the points for certain teams. This is the code I've been using:

Dim teams As DataTable
Dim da As OleDb.OleDbDataAdapter
Dim sql, connStr, teamName As String

connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = "
connStr = connStr & "rogaine.mdb"

teamName = lstTeams.SelectedItem

sql = "SELECT SUM control " & _
"FROM controlVisits " & _
"WHERE team = teamName "

da = New OleDb.OleDbDataAdapter(sql, connStr)
teams = New DataTable

What I'm unsure and having trouble doing is to get the result displayed in a label after the calculation button has been clicked. Any advice would be alot of help thanks.

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Mcdermid
0

I'm trying to calculate a column from a database called rogaine.mdb.
I've been using an SQL statement to do this as I only want to calculate the points for certain teams. This is the code I've been using:

Dim teams As DataTable
Dim da As OleDb.OleDbDataAdapter
Dim sql, connStr, teamName As String

connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = "
connStr = connStr & "rogaine.mdb"

teamName = lstTeams.SelectedItem

sql = "SELECT SUM control " & _
"FROM controlVisits " & _
"WHERE team = teamName "

da = New OleDb.OleDbDataAdapter(sql, connStr)
teams = New DataTable

What I'm unsure and having trouble doing is to get the result displayed in a label after the calculation button has been clicked. Any advice would be alot of help thanks.

try this:

sql = "SELECT SUM (control) As teampoints " & _
              "FROM controlVisits " & _
              "WHERE team = teamName "
0

I tried it but it still isn't letting me get a value in to the label.

To help get a better understand what i want it to do is when i press the calc button it sets the labels text to the sum of the points from the team selected.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.