Hello all,
I am trying to develop a window which does following procedure ;
1 . there are 2 listboxes (active students and passive students) and several names in each listbox.
2 . when i double-click any student name at any listbox, this student moves to the other group (for example, if i db-click on a student item in passive students grup, this item will go to the active listbox.
3 . finally, when i click "OK" button (or update button) , i want it to update the database with active names and passive names as 1 or 0.
I could complete 1st and 2nd procedures but at 3rd one, it doesnt update the database. It works successfully and doesnt send any exception but when i look at the database (related table), i see that the data is not updated.
Here is my code below :
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim con As New Data.SqlClient.SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\db\pesi2000.mdf;Integrated Security=True;User Instance=True")
Dim i As Integer
Try
con.Open()
For i = 0 To actives.Items.Count - 1
Dim updatestr As String = "update aplist set ap='1' where ieid='" + actives.Items(i) + "' "
Dim updateit As New Data.SqlClient.SqlCommand(updatestr, con)
updateit.ExecuteNonQuery()
Next
For i = 0 To passives.Items.Count - 1
Dim updatestr As String = "update aplist set ap='0' where ieid='" + passives.Items(i) + "' "
Dim updateit As New Data.SqlClient.SqlCommand(upadtestr, con)
updateit.ExecuteNonQuery()
Next
Catch ex As Exception
errorstr.Text = ex.ToString 'this is a label
End Try
con.Close()
End Sub
I urgently need help, please. all help is appreciated.
I am trying to develop a window which does following procedure ;
1 . there are 2 listboxes (active students and passive students) and several names in each listbox.
2 . when i double-click any student name at any listbox, this student moves to the other group (for example, if i db-click on a student item in passive students grup, this item will go to the active listbox.
3 . finally, when i click "OK" button (or update button) , i want it to update the database with active names and passive names as 1 or 0.
I could complete 1st and 2nd procedures but at 3rd one, it doesnt update the database. It works successfully and doesnt send any exception but when i look at the database (related table), i see that the data is not updated.
Here is my code below :
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim con As New Data.SqlClient.SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\db\pesi2000.mdf;Integrated Security=True;User Instance=True")
Dim i As Integer
Try
con.Open()
For i = 0 To actives.Items.Count - 1
Dim updatestr As String = "update aplist set ap='1' where ieid='" + actives.Items(i) + "' "
Dim updateit As New Data.SqlClient.SqlCommand(updatestr, con)
updateit.ExecuteNonQuery()
Next
For i = 0 To passives.Items.Count - 1
Dim updatestr As String = "update aplist set ap='0' where ieid='" + passives.Items(i) + "' "
Dim updateit As New Data.SqlClient.SqlCommand(upadtestr, con)
updateit.ExecuteNonQuery()
Next
Catch ex As Exception
errorstr.Text = ex.ToString 'this is a label
End Try
con.Close()
End Sub
I urgently need help, please. all help is appreciated.