list of strings passed into a parameter

Last post 10-19-2006 10:33 PM by pizzamaker74. 4 replies.

Sort Posts:

  • list of strings passed into a parameter

    10-18-2006, 9:37 PM
    • Member
      274 point Member
    • pizzamaker74
    • Member since 09-25-2006, 8:31 PM
    • Melbourne Australia
    • Posts 239

    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.Click

    Dim iVal As Integer = 0

    Dim SelectedCollection As String

    SelectedCollection = ""

    If (lsbUsersAvail.Items).Count > 1 Then

    For iVal = 0 To lsbUsersAvail.Items.Count - 1

    If lsbUsersAvail.Items(iVal).Selected = True Then

    SelectedCollection = SelectedCollection & "," & lsbUsersAvail.Items(iVal).Value

    End If

    Next

    SelectedCollection = Mid(SelectedCollection, 2, Len(SelectedCollection))

    Session.Item("SelectedCollectionSession") = SelectedCollection

    SqlDataSource4.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.

  • Re: list of strings passed into a parameter

    10-18-2006, 10:44 PM
    Answer
    • Contributor
      6,572 point Contributor
    • satish_nagdev
    • Member since 09-21-2006, 10:25 AM
    • Mother Earth
    • Posts 1,432

    hi,

    could you debug your application, i want to know what actual query is being passed. you've for loop for some list, while debugging does it go inside this loop or not.

    also if i am not wrong you've commented out following line

    'SqlDataSource4.UpdateCommand = "UPDATE tblUserDetails SET DeploymentNameID = @DeploymentNameIDparam WHERE (EmployeeNumber IN (" + SelectedCollection + ")".

    seems like it is the cause as i dont see other line for setting updatecommand.

    please check & let me know.

    regards,

    satish

    Kind Attn: If a reply to your post helped you, kindly mark it as Answered.
    __________________________________________________
    Please save Animals Help World Society For Protection Of Animals,
    Protect these speechless creatures of GOD
  • Re: list of strings passed into a parameter

    10-19-2006, 9:18 PM
    • Member
      274 point Member
    • pizzamaker74
    • Member since 09-25-2006, 8:31 PM
    • Melbourne Australia
    • Posts 239

    This works but does not use parameters:

    Protected Sub btnRemoveUsersFromDeployment_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemoveUsersFromDeployment.Click

    Dim iVal2 As Integer = 0

    Dim SelectedCollection2 As String

    SelectedCollection2 = ""

    If (lstUsersToRemoveFromDeployment.Items).Count > 0 Then

    For iVal2 = 0 To lstUsersToRemoveFromDeployment.Items.Count - 1

    If lstUsersToRemoveFromDeployment.Items(iVal2).Selected = True Then

    SelectedCollection2 = SelectedCollection2 & "," & lstUsersToRemoveFromDeployment.Items(iVal2).Value

    End If

    Next

    SelectedCollection2 = Mid(SelectedCollection2, 2, Len(SelectedCollection2))

    Session.Item("SelectedCollectionSession") = SelectedCollection2

    SqlDataSourceInCurrentDeployment.UpdateCommand = "UPDATE tblUserDetails SET DeploymentNameID = null WHERE ((EmployeeNumber IN (" + SelectedCollection2 + ")))"

    SqlDataSourceInCurrentDeployment.Update()

     

    Else

    MsgBox("Please select user(s) first")

    End If

    End Sub

  • Re: list of strings passed into a parameter

    10-19-2006, 9:34 PM
    • Contributor
      6,572 point Contributor
    • satish_nagdev
    • Member since 09-21-2006, 10:25 AM
    • Mother Earth
    • Posts 1,432

    hi,

    i am not clear mate...in earlier post you were passing parameter for DeploymentNameID in update command now you've removed and used null!!!

    i m confused Embarrassed, what is actual problem.

    regards,

    satish.

    Kind Attn: If a reply to your post helped you, kindly mark it as Answered.
    __________________________________________________
    Please save Animals Help World Society For Protection Of Animals,
    Protect these speechless creatures of GOD
  • Re: list of strings passed into a parameter

    10-19-2006, 10:33 PM
    • Member
      274 point Member
    • pizzamaker74
    • Member since 09-25-2006, 8:31 PM
    • Melbourne Australia
    • Posts 239

    I have used the same concept for two different situations.

    In the last post I did I was removing the Deployment name ID created by the first update command.

    cheers.

    Ben.

Page 1 of 1 (5 items)