Hello All:
I have been struggling to find out what could possibly be wrong with this
piece of code. From my understanding of the CONTAINSTABLE Function and using
parameters with a query, this should work. Obviously, I'm missing something!
I have confirmed that the variable strField does contain the proper value to
be used in the CONTAINSTABLE function. For whatever reason, it does not like
the syntax of it. Please take a look.... any suggestions appreciated!
- Brian
' Take the selected value of the drop down box and put it in strField
strField=DropDown.SelectedValue
' Return the value of strField to confirm what it contains
Button1.Attributes.Add("onclick","return confirm('" & strField & "');")
' Define SQL Connection parameters
conTorontoHardware = New SqlConnection( "server='*****';
trusted_connection=true; database=WorkstationsServers" )
' The SQL statement *PROBLEM* It's says: incorrect syntax near @Dropdown
strSearch = "SELECT RANK, * FROM WorkstationsServers," & _
"CONTAINSTABLE( WorkstationsServers, @Dropdown, @searchphrase )
searchTable " & _
"WHERE [KEY] = WorkstationsServers.WSID " & _
"ORDER BY RANK DESC "
cmdSearch = New SqlCommand( strSearch, conTorontoHardware )
With cmdSearch.Parameters:
.Add(New SQLParameter("@Dropdown", strField))
.Add(New SQLParameter("@searchphrase", txtSearchphrase.Text))
End With
conTorontoHardware.Open()