I am using vs 2012 Professional and SQL-Server 2012 Express.
I was trying to run Admin.aspx, that has a textbox to search for users in a db.
However, each time I try to search for a username I get this error
Cannot use a CONTAINS or FREETEXT predicate on table or indexed view 'users' because it is not full-text indexed.
From what I search Full-Text indexing needs to be enabled, for which in my case, it is greyed out in the SQL Server Management Studio and not available (???) in the Express edition.
How can I over come this problem?
Admin.aspx
Imports System.Data.SqlClient
Partial Class Admin
Inherits System.Web.UI.Page
Protected Sub btnSearchUser_Click(sender As Object, e As EventArgs) Handles btnSearchUser.Click
Dim conn As New SqlConnection("Data Source=BRIAN-PC\SQLEXPRESS;Initial Catalog=master_db;Integrated Security=True")
Dim searchComm As String = "SELECT username FROM users WHERE CONTAINS (username, @username)"
Dim searchSQL As New SqlCommand
conn.Open()
searchSQL = New SqlCommand(searchComm, conn)
searchSQL.Parameters.AddWithValue("@username", txtUserSearch.Text)
Dim datareader As SqlDataReader = searchSQL.ExecuteReader()
While datareader.Read
lstUsers.Items.Add(datareader.Item("username"))
End While
datareader.Close()
conn.Close()
End Sub
End Class
As you can see, the user enters a username in the searchbox, and for each record that contains words from the textbox input is added as an item in the listbox.
I'm not convinced you need full-text search to check for equality in a username. Do you think you could use the following instead of CONTAINS
?
SELECT username FROM dbo.users WHERE username = @username;
If you absolutely feel you need full-text search, then:
SQLEXPRADV_x64_ENU.exe
).Example:
CREATE FULLTEXT CATALOG my_catalog;
GO
CREATE FULLTEXT INDEX
ON dbo.users(username LANGUAGE 1033)
KEY INDEX uq_un ON my_catalog;