Hi @StewartBW , Welcome to Microsoft Q&A,
Yes, you can use parameterized queries with SELECT and DELETE commands. Here is the sample code:
Example of SELECT command using parameterized query
Using command As New OleDbCommand("SELECT * FROM [Table] WHERE Column1 = ?", connection)
command.Parameters.AddWithValue("@param1", searchValue)
Using reader As OleDbDataReader = command.ExecuteReader()
While reader.Read()
' Process query results
End While
End Using
End Using
Example of DELETE command using parameterized query
Using command As New OleDbCommand("DELETE FROM [Table] WHERE ConditionColumn = ?", connection)
command.Parameters.AddWithValue("@param1", conditionValue)
command.ExecuteNonQuery()
End Using
The searchValue
and conditionValue
in these examples are the values you need to query or delete.
Best Regards,
Jiale
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.