CONTAINSTABLE Statement - Help please!

B

Brian Reaburn

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()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,140
Latest member
SweetcalmCBDreview
Top