Larry Brister
asked on
vb.net build comma seperated string for use in SQL Server
I have a series of ListBoxes I inherited. (Many)
I need to build a comma selerated string that I can pass into SQL Server
So...
If a person selects Bob, Tim and Larry
strAccomName below would get built as
'Bob','Tim','Larry'
So that when I pass it ito SQL
It can be used as
WHERE a.AccomName in (@strAccomName)
For Each Item As ListItem In ddlAccomName.Items
If Item.Selected Then
strAccomName = strAccomName & Item.Value & ","
End If
Next
balh... blah... blah...
oCom1.Parameters.Add(New SqlParameter("@strAccomNam e", SqlDbType.VarChar)).Value = strAccomName
blah... blah... blah...
I am also open to manipulating them on the SQL Server side.
I need to build a comma selerated string that I can pass into SQL Server
So...
If a person selects Bob, Tim and Larry
strAccomName below would get built as
'Bob','Tim','Larry'
So that when I pass it ito SQL
It can be used as
WHERE a.AccomName in (@strAccomName)
For Each Item As ListItem In ddlAccomName.Items
If Item.Selected Then
strAccomName = strAccomName & Item.Value & ","
End If
Next
balh... blah... blah...
oCom1.Parameters.Add(New SqlParameter("@strAccomNam
blah... blah... blah...
I am also open to manipulating them on the SQL Server side.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Will check when I am back in front of my pc
ASKER
Thanks!
Open in new window