Click here to Skip to main content
15,796,299 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have many columns in database table in which one is of bool type (1/0) and number of user records associated with manager id like mid 1 has 20 users rows and mid 2 has associated to 35 rows.

In the UI, having one checkbox. When you deselect the check box, it should check at least one user is having this checkbox as checked (true - 1 in database). If not, throw an error message stating that at least one user associated with this mid should be checked with this checkbox field.

Can i try like this
In the method i will write select count(*) from tblEmp where mid = @valueparameter
In the code behind, assigning dataset to variable and if variable.count >= 1 then allow to submit or other operation
else throw warning message (not allow submit).

What I have tried:

Method to get users:
Public Function GetUsersInfo() As System.Data.DataSet
       Dim sql As String = "SELECT * from tblEmp where mid = @PO"
       Dim theDBH_v2 As New DBHelper_v2
       Return (theDBH_v2.ExecuteGetDataSetSQL(sql))
End Function

If CheckContractApprover.Checked = False Then
'Here fetching the data using above method is fine, how to check at least one user is checked in this field.
            End If
Updated 28-May-21 3:31am
SeanChupas 28-May-21 8:23am    
I don't quite follow you but something like

SELECT COUNT(*) FROM table WHERE field = 1

sounds like is what you need.

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