Richard Deeming
Предполагая открытый OracleConnection
экземпляр называется YourConnectionHere
:
Using command As New OracleCommand()
command.Connection = YourConnectionHere
Dim sb As New StringBuilder("DELETE FROM table_1 WHERE column1 IN (")
Dim valuesToDelete As String() = TextBox1.Text.Split(vbNewLine)
For i As Integer = 0 To valuesToDelete.Length - 1
If i > 0 Then sb.Append(", ")
Dim name As String = "@p" & i
sb.Append(name)
command.Parameters.AddWithValue(name, valuesToDelete(i))
Next
sb.Append(")");
command.CommandText = sb.ToString()
command.ExecuteNonQuery()
End Using
В качестве альтернативы используйте
Щеголеватый[
^]:
Dim valuesToDelete As String() = TextBox1.Text.Split(vbNewLine)
YourConnectionHere.Execute("DELETE FROM table_1 WHERE column1 IN (@ValuesToDelete)", New With { .ValuesToDelete = valuesToDelete })