I am using SQL Server 2016 Visual studio 2017.
Need to fill checkedlistbox2, from my database, based on the value of the SelectedItem of Checkedlistbox1.
I am filling checkedlistbox1 on [login to view URL] as below: This code is working.
Private Sub fillChkboxList()
Dim conn As New SqlConnection("Data Source=[login to view URL];user id=sa;password=XXXX@123;database=XXXXXXX")
Dim sda As New SqlDataAdapter("select DepartmentName, DepartmentID from DepartmentMain where active=1 order by DepartmentName", conn)
Dim dt As New DataTable
[login to view URL](dt)
[login to view URL] = dt
[login to view URL] = "DepartmentName"
[login to view URL] = "DepartmentID"
Here I am trying to use a method to fill Checkedlistbox2, which I am calling in the ItemCheck event handler of Checkedlistbox1:
Below Code is not giving required results
Public Function fillChkboxListSub()
Dim i As Integer
Dim conn1 As New SqlConnection("Data Source=[login to view URL];user id=sa;password=XXXX@123;database=XXXXXXX")
For i = 0 To [login to view URL] - 1 Step i + 1
If [login to view URL](i) = [login to view URL] Then
Dim xx As String = (CType([login to view URL](i), DataRowView))("DepartmentID")
Dim sqlstr2 As String = "select SubName,SubDeptID from DepartmentSub where active=1 and DepartmentID in ('" & xx & "') order by SubName"
Dim command2 As New SqlCommand(sqlstr2, conn1)
Dim adpt2 As New SqlDataAdapter(command2)
[login to view URL] = command2
[login to view URL](dt2)
[login to view URL] = dt2
[login to view URL] = "SubName"
[login to view URL] = "SubDeptID"
This function I am calling on:
Private Sub CheckedListBox1_ItemCheck(sender As Object, e As ItemCheckEventArgs) Handles [login to view URL]
I am not getting the result.
If I check the (DepartmentName) in checkedlistbox1, SubDeptName should load in checkedlistbox2. If I deselect the same in checkedlistbox1, it should be deleted or removed from checkedlistbox2Please help with working code example. Thanks in Advance
10 freelancere byder i gennemsnit ₹443/timen for dette job
Give it to me, i'm will sloved it. I have experienced in windows applications development using c# and vb.net. so if you want to assign this task, I will complete this