In retrieving data from Sql server database I use the following Sqlcommand:
comm = New SqlCommand("SELECT COUNT(*) FROM Main where tType=@tType And dDate=@dDate And sSubject like 'compass%'", con)
I then use parameters to enter the data type and values for dDate and tType.
My problem is that I need to do the same with sSubject, so that the Sqlcommand would look like the following:
comm = New SqlCommand("SELECT COUNT(*) FROM Main where tType=@tType And dDate=@dDate And sSubject=@sSubject", con)
The difficulty here is assigning a value to the sSubject parameters:
comm.Parameters("@sSubject").Value = "like 'compass%'"
Obviously the way I entered the value is wrong because it is not working.
But how else can I assign a value using "Like" followed by the word that should be searched and the "%" to indicate any other word that follow ...???