Suppose that I have, for example:
Dim _id As Integer = 7
And I'm going to use it to select a row from a table where foo_id is the primary key. Either I can bind the Integer value with AddWithValue such as:
Dim cmd As New SqlCommand("select * from foo where foo_id = @id", sqlconn)
cmd.Parameters.AddWithValue("@id", _id)
Or I can construct the statement as a pure string:
Dim cmd As New SqlCommand("select * from foo where foo_id = " & _id, sqlconn)
Obviously I would always, always bind a string, but with an Integer key I can talk myself into either method.
Anybody have an opinion either way, and why?