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.

Recommended Answers

All 2 Replies

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 "

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.