Click here to Skip to main content
15,894,343 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hai , i have a probleam to display total row from database after i delete current user. I am using button delete to remove data form database. After remove the data I want to display total current user form database .For this process i am using command me.StaffDataGridView.Row.Count to get total of row from database.After i remove the current user i only get answer There Are 1 Staff Register .For your info i have 23 total row in my table which i name it as staff. Here is my coding which i am using sql 2005 and visual studio 2005. Please correct my coding please.

VB
Public Class User
Dim count As Integer = 0

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnremove1.Click
MsgBox(" Are You Confirm ?", MsgBoxStyle.YesNo) = vbYes Then
Me.StaffBindingSource.RemoveCurrent()
Me.StaffBindingSource.EndEdit()
Me.StaffTableAdapter.Update(Me.LoginDataSet.staff)
Me.ValidateChildren()
End Sub

Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
count = Me.StaffDataGridView.Row.Count
Label5.Text = "There Are " & count & " Staff Register"
End Sub
End class
Posted
Updated 5-Oct-11 2:57am
v2

1 solution

First, you need to change

VB
count = Me.StaffDataGridView.Row.Count


to

VB
count = Me.StaffDataGridView.Rows.Count


You don't have all your code. First, is the timer firing ticks? It doesn't show anywhere, so you'll want to double check that.

Then, setup a break point at

VB
count = Me.StaffDataGridView.Rows.Count


What is the value of Me.StaffDataGridView.Rows.Count?

You might also consider changing the count to a property. When it's a property, you can set a break point withing the "SET", so that you can see when and what value it's being changed to.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900