Help about how to get sum of the column

  • Thread starter Thread starter clynnekent
  • Start date Start date
C

clynnekent

Guest
Good day,everyone can I ask how to get the sum of the column. I started learning few days ago in VB.net since VB 6.0 is not supported by Microsoft nowadays.


Here is the sample program I make..


Dim ctr, i As Integer

'cn.Open()
str = "select * from tblarecord where empid = '" & TextBox1.Text & "' ORDER BY empid ASC"
cmd = New OleDbCommand(str, cn)
da.SelectCommand = cmd
da.Fill(ds, "tblarecord")
ctr = ds.Tables("tblarecord").Rows.Count - 1
For i = 0 To ctr

DataGridView1.Rows.Add(ds.Tables("tblarecord").Rows(i)(0).ToString, ds.Tables("tblarecord").Rows(i)(1).ToString, ds.Tables("tblarecord").Rows(i)(2).ToString, ds.Tables("tblarecord").Rows(i)(3).ToString, ds.Tables("tblarecord").Rows(i)(4).ToString, ds.Tables("tblarecord").Rows(i)(5).ToString, ds.Tables("tblarecord").Rows(i)(6).ToString, ds.Tables("tblarecord").Rows(i)(7).ToString)

Next


For sum = 0 To DataGridView1.Rows.Count() - 1 Step +1

TextBox2.Text = sum + DataGridView1.Rows(i).Cells(0).Value



Next




TextBox2.Text is my problem coz the value he get is the rows. So I want to get the column of data DataGrid.

if ID number search, dataGridView display the how many absences of the student and display it to TextBox2.Text.

I hope all can help me about it.Its project porpuses.


Thanks in advance

Clynnekent

Continue reading...
 
Back
Top