I have a database of gigs that I'm searching by Artist and trying to use LIKE in the sql query but failing.
I have tried:
string strSQL = "SELECT * FROM TB_CA_gigs WHERE Artist LIKE '[%" + Artist + "%]'";
which brings back no records
string strSQL = "SELECT * FROM TB_CA_gigs WHERE Artist LIKE '%[" + Artist + "]%'";
which brings back all records
string strSQL = "SELECT * FROM TB_CA_gigs WHERE Artist LIKE '" + Artist + "'";
which brings back no records
I have tried using CONTAINS in various ways but always get the same error:
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'CONTAINS'. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlDataReader.ConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader() at WebService1.Service1.Search(String Artist) in C:\Users\strscac\Desktop\VS\WebService1\WebService1\WebService1\Service1.asmx.cs:line 36