S
Sparky Arbuckle
I am looping through a listbox collection to build a SQL string that
will be used to delete items from a database. I have tried many
variances of the code below but have had no luck. The code below gives
an error:
Cast from type 'ListItem' to type 'String' is not valid.
When i do a response.write(s) the item at the top row displays
correctly. Here is the code I am using:
Private Sub btnDeleteDrawings_Click(ByVal ...)
Dim i As Integer = 0
Dim s As String = lbColumn2.Items(0).Text.ToString
Dim strSQL As String = "DELETE FROM tbl X Y Z Where "
For Each s In lbColumn2.Items '<- Error thrown here
strSQL += "Text = '" & s & "'"
lbColumn2.SelectedIndex = -1
If c > 1 Then
strSQL += " AND "
Else
strSQL += ";"
End If
lbColumn2.Items.Remove(s)
Next
End Sub
will be used to delete items from a database. I have tried many
variances of the code below but have had no luck. The code below gives
an error:
Cast from type 'ListItem' to type 'String' is not valid.
When i do a response.write(s) the item at the top row displays
correctly. Here is the code I am using:
Private Sub btnDeleteDrawings_Click(ByVal ...)
Dim i As Integer = 0
Dim s As String = lbColumn2.Items(0).Text.ToString
Dim strSQL As String = "DELETE FROM tbl X Y Z Where "
For Each s In lbColumn2.Items '<- Error thrown here
strSQL += "Text = '" & s & "'"
lbColumn2.SelectedIndex = -1
If c > 1 Then
strSQL += " AND "
Else
strSQL += ";"
End If
lbColumn2.Items.Remove(s)
Next
End Sub