SQL Server contains predicate not working with multiple search terms












-1















I have a c# program that searches a table by the user's input.



The keywords are split by a space and saved into an array.



Then the switch statement will select the correct case based on having only entered one word, or two words.



My switch statement only fills my datagrid for first case, but when attempting to use 2nd case, my program goes to the catch exception.



I tried debugging, but the only thing I see is that when I enter case 2, it does not step beyond sda1.Fill(dt1);



Updated code:



static string myconnstr = ConfigurationManager.ConnectionStrings["connstrng"].ConnectionString;       

private void btnSearch_Click(object sender, EventArgs e)
{
//Get the value from textbox
string keyword = txtboxKeyword.Text;
string words = keyword.Split(' ');

//SQL Connection
var conn = new SqlConnection(myconnstr);

try
{
switch (words.Length)
{
case 1:
//Declare Command object with parameter
SqlCommand cmd = new SqlCommand("SELECT Site, StreetAddress, City, State, Zip, PharmacyPhone, MDVersion, InstallDate, SiteCodes, SiteNotActive, CloseDate, SiteNotes " +
"FROM Sites WHERE contains(site, @words0) OR contains (StreetAddress, @words0) OR contains(city, @words0)", conn);

cmd.Parameters.AddWithValue("@words0", words[0]);

SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
dataGridSites.ReadOnly = true;
dataGridSites.DataSource = dt;
dataGridSites.CurrentCell = null;
break;
case 2:
//Declare Command object with parameter
SqlCommand cmd1 = new SqlCommand("SELECT Site, StreetAddress, City, State, Zip, PharmacyPhone, MDVersion, InstallDate, SiteCodes, SiteNotActive, CloseDate, SiteNotes " +
"FROM Sites WHERE contains(site, @words0, @words1) OR contains (StreetAddress, @words0, @words1) OR contains(city, @words0, @words1)", conn);

cmd1.Parameters.AddWithValue("@words0", words[0]);
cmd1.Parameters.AddWithValue("@words1", words[1]);

SqlDataAdapter sda1 = new SqlDataAdapter(cmd1);
DataTable dt1 = new DataTable();
sda1.Fill(dt1);
dataGridSites.ReadOnly = true;
dataGridSites.DataSource = dt1;
dataGridSites.CurrentCell = null;
break;
}
}
catch (Exception)
{
MessageBox.Show("Search cannot be blank.");
}
}


Here is updated exception error I am getting:




System.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near
'@words1'. Error Number:102,State:1,Class:15











share|improve this question




















  • 4





    Getting more information about the exception would help us tremendously, but I haven't seen contains() used with "and" before. Try replacing contains(city, @words0 and @words1) with contains(city, @words0, @words1)

    – Thorin Jacobs
    Nov 28 '18 at 20:11








  • 2





    I would rethink your approach, I would create a valid method for each filter instance and then create a Dictionary<string, Func<SqlParameter, Model>> to call a dictionary with a method to be executed explicitly. Then simply call the key you want, then use .Invoke to execute the proper implementation rather than a switch with case. It will be more expressive in my opinion. You receive the valid model of the data from the filter, then bind to your control.

    – Greg
    Nov 28 '18 at 20:16


















-1















I have a c# program that searches a table by the user's input.



The keywords are split by a space and saved into an array.



Then the switch statement will select the correct case based on having only entered one word, or two words.



My switch statement only fills my datagrid for first case, but when attempting to use 2nd case, my program goes to the catch exception.



I tried debugging, but the only thing I see is that when I enter case 2, it does not step beyond sda1.Fill(dt1);



Updated code:



static string myconnstr = ConfigurationManager.ConnectionStrings["connstrng"].ConnectionString;       

private void btnSearch_Click(object sender, EventArgs e)
{
//Get the value from textbox
string keyword = txtboxKeyword.Text;
string words = keyword.Split(' ');

//SQL Connection
var conn = new SqlConnection(myconnstr);

try
{
switch (words.Length)
{
case 1:
//Declare Command object with parameter
SqlCommand cmd = new SqlCommand("SELECT Site, StreetAddress, City, State, Zip, PharmacyPhone, MDVersion, InstallDate, SiteCodes, SiteNotActive, CloseDate, SiteNotes " +
"FROM Sites WHERE contains(site, @words0) OR contains (StreetAddress, @words0) OR contains(city, @words0)", conn);

cmd.Parameters.AddWithValue("@words0", words[0]);

SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
dataGridSites.ReadOnly = true;
dataGridSites.DataSource = dt;
dataGridSites.CurrentCell = null;
break;
case 2:
//Declare Command object with parameter
SqlCommand cmd1 = new SqlCommand("SELECT Site, StreetAddress, City, State, Zip, PharmacyPhone, MDVersion, InstallDate, SiteCodes, SiteNotActive, CloseDate, SiteNotes " +
"FROM Sites WHERE contains(site, @words0, @words1) OR contains (StreetAddress, @words0, @words1) OR contains(city, @words0, @words1)", conn);

cmd1.Parameters.AddWithValue("@words0", words[0]);
cmd1.Parameters.AddWithValue("@words1", words[1]);

SqlDataAdapter sda1 = new SqlDataAdapter(cmd1);
DataTable dt1 = new DataTable();
sda1.Fill(dt1);
dataGridSites.ReadOnly = true;
dataGridSites.DataSource = dt1;
dataGridSites.CurrentCell = null;
break;
}
}
catch (Exception)
{
MessageBox.Show("Search cannot be blank.");
}
}


Here is updated exception error I am getting:




System.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near
'@words1'. Error Number:102,State:1,Class:15











share|improve this question




















  • 4





    Getting more information about the exception would help us tremendously, but I haven't seen contains() used with "and" before. Try replacing contains(city, @words0 and @words1) with contains(city, @words0, @words1)

    – Thorin Jacobs
    Nov 28 '18 at 20:11








  • 2





    I would rethink your approach, I would create a valid method for each filter instance and then create a Dictionary<string, Func<SqlParameter, Model>> to call a dictionary with a method to be executed explicitly. Then simply call the key you want, then use .Invoke to execute the proper implementation rather than a switch with case. It will be more expressive in my opinion. You receive the valid model of the data from the filter, then bind to your control.

    – Greg
    Nov 28 '18 at 20:16
















-1












-1








-1








I have a c# program that searches a table by the user's input.



The keywords are split by a space and saved into an array.



Then the switch statement will select the correct case based on having only entered one word, or two words.



My switch statement only fills my datagrid for first case, but when attempting to use 2nd case, my program goes to the catch exception.



I tried debugging, but the only thing I see is that when I enter case 2, it does not step beyond sda1.Fill(dt1);



Updated code:



static string myconnstr = ConfigurationManager.ConnectionStrings["connstrng"].ConnectionString;       

private void btnSearch_Click(object sender, EventArgs e)
{
//Get the value from textbox
string keyword = txtboxKeyword.Text;
string words = keyword.Split(' ');

//SQL Connection
var conn = new SqlConnection(myconnstr);

try
{
switch (words.Length)
{
case 1:
//Declare Command object with parameter
SqlCommand cmd = new SqlCommand("SELECT Site, StreetAddress, City, State, Zip, PharmacyPhone, MDVersion, InstallDate, SiteCodes, SiteNotActive, CloseDate, SiteNotes " +
"FROM Sites WHERE contains(site, @words0) OR contains (StreetAddress, @words0) OR contains(city, @words0)", conn);

cmd.Parameters.AddWithValue("@words0", words[0]);

SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
dataGridSites.ReadOnly = true;
dataGridSites.DataSource = dt;
dataGridSites.CurrentCell = null;
break;
case 2:
//Declare Command object with parameter
SqlCommand cmd1 = new SqlCommand("SELECT Site, StreetAddress, City, State, Zip, PharmacyPhone, MDVersion, InstallDate, SiteCodes, SiteNotActive, CloseDate, SiteNotes " +
"FROM Sites WHERE contains(site, @words0, @words1) OR contains (StreetAddress, @words0, @words1) OR contains(city, @words0, @words1)", conn);

cmd1.Parameters.AddWithValue("@words0", words[0]);
cmd1.Parameters.AddWithValue("@words1", words[1]);

SqlDataAdapter sda1 = new SqlDataAdapter(cmd1);
DataTable dt1 = new DataTable();
sda1.Fill(dt1);
dataGridSites.ReadOnly = true;
dataGridSites.DataSource = dt1;
dataGridSites.CurrentCell = null;
break;
}
}
catch (Exception)
{
MessageBox.Show("Search cannot be blank.");
}
}


Here is updated exception error I am getting:




System.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near
'@words1'. Error Number:102,State:1,Class:15











share|improve this question
















I have a c# program that searches a table by the user's input.



The keywords are split by a space and saved into an array.



Then the switch statement will select the correct case based on having only entered one word, or two words.



My switch statement only fills my datagrid for first case, but when attempting to use 2nd case, my program goes to the catch exception.



I tried debugging, but the only thing I see is that when I enter case 2, it does not step beyond sda1.Fill(dt1);



Updated code:



static string myconnstr = ConfigurationManager.ConnectionStrings["connstrng"].ConnectionString;       

private void btnSearch_Click(object sender, EventArgs e)
{
//Get the value from textbox
string keyword = txtboxKeyword.Text;
string words = keyword.Split(' ');

//SQL Connection
var conn = new SqlConnection(myconnstr);

try
{
switch (words.Length)
{
case 1:
//Declare Command object with parameter
SqlCommand cmd = new SqlCommand("SELECT Site, StreetAddress, City, State, Zip, PharmacyPhone, MDVersion, InstallDate, SiteCodes, SiteNotActive, CloseDate, SiteNotes " +
"FROM Sites WHERE contains(site, @words0) OR contains (StreetAddress, @words0) OR contains(city, @words0)", conn);

cmd.Parameters.AddWithValue("@words0", words[0]);

SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
dataGridSites.ReadOnly = true;
dataGridSites.DataSource = dt;
dataGridSites.CurrentCell = null;
break;
case 2:
//Declare Command object with parameter
SqlCommand cmd1 = new SqlCommand("SELECT Site, StreetAddress, City, State, Zip, PharmacyPhone, MDVersion, InstallDate, SiteCodes, SiteNotActive, CloseDate, SiteNotes " +
"FROM Sites WHERE contains(site, @words0, @words1) OR contains (StreetAddress, @words0, @words1) OR contains(city, @words0, @words1)", conn);

cmd1.Parameters.AddWithValue("@words0", words[0]);
cmd1.Parameters.AddWithValue("@words1", words[1]);

SqlDataAdapter sda1 = new SqlDataAdapter(cmd1);
DataTable dt1 = new DataTable();
sda1.Fill(dt1);
dataGridSites.ReadOnly = true;
dataGridSites.DataSource = dt1;
dataGridSites.CurrentCell = null;
break;
}
}
catch (Exception)
{
MessageBox.Show("Search cannot be blank.");
}
}


Here is updated exception error I am getting:




System.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near
'@words1'. Error Number:102,State:1,Class:15








c# sql-server full-text-search






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 28 '18 at 20:57









mjwills

15.9k42643




15.9k42643










asked Nov 28 '18 at 20:03









Andriks SalvatierraAndriks Salvatierra

62




62








  • 4





    Getting more information about the exception would help us tremendously, but I haven't seen contains() used with "and" before. Try replacing contains(city, @words0 and @words1) with contains(city, @words0, @words1)

    – Thorin Jacobs
    Nov 28 '18 at 20:11








  • 2





    I would rethink your approach, I would create a valid method for each filter instance and then create a Dictionary<string, Func<SqlParameter, Model>> to call a dictionary with a method to be executed explicitly. Then simply call the key you want, then use .Invoke to execute the proper implementation rather than a switch with case. It will be more expressive in my opinion. You receive the valid model of the data from the filter, then bind to your control.

    – Greg
    Nov 28 '18 at 20:16
















  • 4





    Getting more information about the exception would help us tremendously, but I haven't seen contains() used with "and" before. Try replacing contains(city, @words0 and @words1) with contains(city, @words0, @words1)

    – Thorin Jacobs
    Nov 28 '18 at 20:11








  • 2





    I would rethink your approach, I would create a valid method for each filter instance and then create a Dictionary<string, Func<SqlParameter, Model>> to call a dictionary with a method to be executed explicitly. Then simply call the key you want, then use .Invoke to execute the proper implementation rather than a switch with case. It will be more expressive in my opinion. You receive the valid model of the data from the filter, then bind to your control.

    – Greg
    Nov 28 '18 at 20:16










4




4





Getting more information about the exception would help us tremendously, but I haven't seen contains() used with "and" before. Try replacing contains(city, @words0 and @words1) with contains(city, @words0, @words1)

– Thorin Jacobs
Nov 28 '18 at 20:11







Getting more information about the exception would help us tremendously, but I haven't seen contains() used with "and" before. Try replacing contains(city, @words0 and @words1) with contains(city, @words0, @words1)

– Thorin Jacobs
Nov 28 '18 at 20:11






2




2





I would rethink your approach, I would create a valid method for each filter instance and then create a Dictionary<string, Func<SqlParameter, Model>> to call a dictionary with a method to be executed explicitly. Then simply call the key you want, then use .Invoke to execute the proper implementation rather than a switch with case. It will be more expressive in my opinion. You receive the valid model of the data from the filter, then bind to your control.

– Greg
Nov 28 '18 at 20:16







I would rethink your approach, I would create a valid method for each filter instance and then create a Dictionary<string, Func<SqlParameter, Model>> to call a dictionary with a method to be executed explicitly. Then simply call the key you want, then use .Invoke to execute the proper implementation rather than a switch with case. It will be more expressive in my opinion. You receive the valid model of the data from the filter, then bind to your control.

– Greg
Nov 28 '18 at 20:16














2 Answers
2






active

oldest

votes


















0














The reason your existing code doesn't work is that contains doesn't support three parameters in the way you are currently trying to call it.



As per the documentation, I would suggest changing:



FROM Sites WHERE contains(site, @words0) OR contains (StreetAddress, @words0) OR contains(city, @words0)


to:



FROM Sites WHERE contains((site, StreetAddress, city), @words0)


And:



FROM Sites WHERE contains(site, @words0, @words1) OR contains (StreetAddress, @words0, @words1) OR contains(city, @words0, @words1)


to:



FROM Sites WHERE contains((site, StreetAddress, city), @words0) OR contains((site, StreetAddress, city), @words1)


If you really want to use your current more verbose style, then Example I suggests that:



FROM Sites WHERE contains(site, @wordsConcat) OR contains (StreetAddress, @wordsConcat) OR contains(city, @wordsConcat)


may work, where @wordsConcat has been set (by C#) to:



words[0] + " OR " + words[1]





share|improve this answer


























  • Thank you! I made the changes per your suggestion and this fixed my issue.

    – Andriks Salvatierra
    Nov 29 '18 at 14:17



















-6














I think it is a scope problem' knowen with switch case, for historical reasons.That why we have to put break after each statment. Try to have a look here.
Variable declaration in a C# switch statement






share|improve this answer



















  • 4





    You don't put a break after each statement. You only put it once after the whole case block is done to prevent fall through.

    – Xiaoy312
    Nov 28 '18 at 20:15






  • 1





    I don't understand how this is relevant to the question. The link provided (which links shouldn't be used as answers) is referring to declaring variables within the switch case using the same names as others declared within the following switch case(s). The OP has used unique variable names in each switch case here already.

    – Michael Puckett II
    Nov 28 '18 at 20:20












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53527281%2fsql-server-contains-predicate-not-working-with-multiple-search-terms%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














The reason your existing code doesn't work is that contains doesn't support three parameters in the way you are currently trying to call it.



As per the documentation, I would suggest changing:



FROM Sites WHERE contains(site, @words0) OR contains (StreetAddress, @words0) OR contains(city, @words0)


to:



FROM Sites WHERE contains((site, StreetAddress, city), @words0)


And:



FROM Sites WHERE contains(site, @words0, @words1) OR contains (StreetAddress, @words0, @words1) OR contains(city, @words0, @words1)


to:



FROM Sites WHERE contains((site, StreetAddress, city), @words0) OR contains((site, StreetAddress, city), @words1)


If you really want to use your current more verbose style, then Example I suggests that:



FROM Sites WHERE contains(site, @wordsConcat) OR contains (StreetAddress, @wordsConcat) OR contains(city, @wordsConcat)


may work, where @wordsConcat has been set (by C#) to:



words[0] + " OR " + words[1]





share|improve this answer


























  • Thank you! I made the changes per your suggestion and this fixed my issue.

    – Andriks Salvatierra
    Nov 29 '18 at 14:17
















0














The reason your existing code doesn't work is that contains doesn't support three parameters in the way you are currently trying to call it.



As per the documentation, I would suggest changing:



FROM Sites WHERE contains(site, @words0) OR contains (StreetAddress, @words0) OR contains(city, @words0)


to:



FROM Sites WHERE contains((site, StreetAddress, city), @words0)


And:



FROM Sites WHERE contains(site, @words0, @words1) OR contains (StreetAddress, @words0, @words1) OR contains(city, @words0, @words1)


to:



FROM Sites WHERE contains((site, StreetAddress, city), @words0) OR contains((site, StreetAddress, city), @words1)


If you really want to use your current more verbose style, then Example I suggests that:



FROM Sites WHERE contains(site, @wordsConcat) OR contains (StreetAddress, @wordsConcat) OR contains(city, @wordsConcat)


may work, where @wordsConcat has been set (by C#) to:



words[0] + " OR " + words[1]





share|improve this answer


























  • Thank you! I made the changes per your suggestion and this fixed my issue.

    – Andriks Salvatierra
    Nov 29 '18 at 14:17














0












0








0







The reason your existing code doesn't work is that contains doesn't support three parameters in the way you are currently trying to call it.



As per the documentation, I would suggest changing:



FROM Sites WHERE contains(site, @words0) OR contains (StreetAddress, @words0) OR contains(city, @words0)


to:



FROM Sites WHERE contains((site, StreetAddress, city), @words0)


And:



FROM Sites WHERE contains(site, @words0, @words1) OR contains (StreetAddress, @words0, @words1) OR contains(city, @words0, @words1)


to:



FROM Sites WHERE contains((site, StreetAddress, city), @words0) OR contains((site, StreetAddress, city), @words1)


If you really want to use your current more verbose style, then Example I suggests that:



FROM Sites WHERE contains(site, @wordsConcat) OR contains (StreetAddress, @wordsConcat) OR contains(city, @wordsConcat)


may work, where @wordsConcat has been set (by C#) to:



words[0] + " OR " + words[1]





share|improve this answer















The reason your existing code doesn't work is that contains doesn't support three parameters in the way you are currently trying to call it.



As per the documentation, I would suggest changing:



FROM Sites WHERE contains(site, @words0) OR contains (StreetAddress, @words0) OR contains(city, @words0)


to:



FROM Sites WHERE contains((site, StreetAddress, city), @words0)


And:



FROM Sites WHERE contains(site, @words0, @words1) OR contains (StreetAddress, @words0, @words1) OR contains(city, @words0, @words1)


to:



FROM Sites WHERE contains((site, StreetAddress, city), @words0) OR contains((site, StreetAddress, city), @words1)


If you really want to use your current more verbose style, then Example I suggests that:



FROM Sites WHERE contains(site, @wordsConcat) OR contains (StreetAddress, @wordsConcat) OR contains(city, @wordsConcat)


may work, where @wordsConcat has been set (by C#) to:



words[0] + " OR " + words[1]






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 28 '18 at 21:01

























answered Nov 28 '18 at 20:45









mjwillsmjwills

15.9k42643




15.9k42643













  • Thank you! I made the changes per your suggestion and this fixed my issue.

    – Andriks Salvatierra
    Nov 29 '18 at 14:17



















  • Thank you! I made the changes per your suggestion and this fixed my issue.

    – Andriks Salvatierra
    Nov 29 '18 at 14:17

















Thank you! I made the changes per your suggestion and this fixed my issue.

– Andriks Salvatierra
Nov 29 '18 at 14:17





Thank you! I made the changes per your suggestion and this fixed my issue.

– Andriks Salvatierra
Nov 29 '18 at 14:17













-6














I think it is a scope problem' knowen with switch case, for historical reasons.That why we have to put break after each statment. Try to have a look here.
Variable declaration in a C# switch statement






share|improve this answer



















  • 4





    You don't put a break after each statement. You only put it once after the whole case block is done to prevent fall through.

    – Xiaoy312
    Nov 28 '18 at 20:15






  • 1





    I don't understand how this is relevant to the question. The link provided (which links shouldn't be used as answers) is referring to declaring variables within the switch case using the same names as others declared within the following switch case(s). The OP has used unique variable names in each switch case here already.

    – Michael Puckett II
    Nov 28 '18 at 20:20
















-6














I think it is a scope problem' knowen with switch case, for historical reasons.That why we have to put break after each statment. Try to have a look here.
Variable declaration in a C# switch statement






share|improve this answer



















  • 4





    You don't put a break after each statement. You only put it once after the whole case block is done to prevent fall through.

    – Xiaoy312
    Nov 28 '18 at 20:15






  • 1





    I don't understand how this is relevant to the question. The link provided (which links shouldn't be used as answers) is referring to declaring variables within the switch case using the same names as others declared within the following switch case(s). The OP has used unique variable names in each switch case here already.

    – Michael Puckett II
    Nov 28 '18 at 20:20














-6












-6








-6







I think it is a scope problem' knowen with switch case, for historical reasons.That why we have to put break after each statment. Try to have a look here.
Variable declaration in a C# switch statement






share|improve this answer













I think it is a scope problem' knowen with switch case, for historical reasons.That why we have to put break after each statment. Try to have a look here.
Variable declaration in a C# switch statement







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 28 '18 at 20:09









Netanel RNetanel R

215




215








  • 4





    You don't put a break after each statement. You only put it once after the whole case block is done to prevent fall through.

    – Xiaoy312
    Nov 28 '18 at 20:15






  • 1





    I don't understand how this is relevant to the question. The link provided (which links shouldn't be used as answers) is referring to declaring variables within the switch case using the same names as others declared within the following switch case(s). The OP has used unique variable names in each switch case here already.

    – Michael Puckett II
    Nov 28 '18 at 20:20














  • 4





    You don't put a break after each statement. You only put it once after the whole case block is done to prevent fall through.

    – Xiaoy312
    Nov 28 '18 at 20:15






  • 1





    I don't understand how this is relevant to the question. The link provided (which links shouldn't be used as answers) is referring to declaring variables within the switch case using the same names as others declared within the following switch case(s). The OP has used unique variable names in each switch case here already.

    – Michael Puckett II
    Nov 28 '18 at 20:20








4




4





You don't put a break after each statement. You only put it once after the whole case block is done to prevent fall through.

– Xiaoy312
Nov 28 '18 at 20:15





You don't put a break after each statement. You only put it once after the whole case block is done to prevent fall through.

– Xiaoy312
Nov 28 '18 at 20:15




1




1





I don't understand how this is relevant to the question. The link provided (which links shouldn't be used as answers) is referring to declaring variables within the switch case using the same names as others declared within the following switch case(s). The OP has used unique variable names in each switch case here already.

– Michael Puckett II
Nov 28 '18 at 20:20





I don't understand how this is relevant to the question. The link provided (which links shouldn't be used as answers) is referring to declaring variables within the switch case using the same names as others declared within the following switch case(s). The OP has used unique variable names in each switch case here already.

– Michael Puckett II
Nov 28 '18 at 20:20


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53527281%2fsql-server-contains-predicate-not-working-with-multiple-search-terms%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Contact image not getting when fetch all contact list from iPhone by CNContact

count number of partitions of a set with n elements into k subsets

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks