Question Cannot display total row from database

Iswan

Member
Joined
Aug 9, 2011
Messages
8
Programming Experience
Beginner
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.StaffBindingSource .Count to get total of row from database.After i remove the current user i only get answer There Are 0 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.

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()


count = Me.StaffBindingSource.Count

Label5.Text = "There Are " & count & " Staff Register"

End Sub


End class
 
It doesn't matter how many records you have in your database table because that's not the count that you're using. It only matters how many items you have in your BindingSource. If the message says zero then you have zero items in your BindingSource.

That said, the code you have posted wouldn't even compile so it's obviously not the actual code you're running. As such, we don't even really know if you're doing what you say that you're doing.
 
Back
Top