I am trying to pass multiple values as parameters into my update command:
UPDATE tblUserDetails SET DeploymentNameID = 102 WHERE ((EmployeeNumber IN (@selectedusersparam)));
I develop my parameter (@selectedusersparam) using the following subroutine:
Private Sub btnAddUsersToDeployment_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddUsersToDeployment.ClickDim iVal As Integer = 0Dim SelectedCollection As String
SelectedCollection = ""
If (lsbUsersAvail.Items).Count > 1 Then
For iVal = 0 To lsbUsersAvail.Items.Count - 1If lsbUsersAvail.Items(iVal).Selected = True Then
SelectedCollection = SelectedCollection & "," & lsbUsersAvail.Items(iVal).ValueEnd If
Next
SelectedCollection = Mid(SelectedCollection, 2, Len(SelectedCollection))
Session.Item("SelectedCollectionSession") = SelectedCollectionSqlDataSource4.Update()
ltlUsersMessage.Text = String.Empty
'UPDATE tblUserDetails SET DeploymentNameID = @DeploymentNameIDparam WHERE (EmployeeNumber IN (@selectedusersparam))
'SqlDataSource4.UpdateCommand = "UPDATE tblUserDetails SET DeploymentNameID = @DeploymentNameIDparam WHERE (EmployeeNumber IN (" + SelectedCollection + ")"
Else
ltlUsersMessage.Text = "Select users before adding to deployment. Hold Control for multiselect"
End If
End Sub
For some reason the query does not pass the parameters which are "21077679,22648722,22652940,21080617" into the query
I don't understand why.