I have updated my code with the help of you all, but still have the problem where '*' wildcard does not work with my program:
I have a C# program that has an array of words given to it by an input field.
I can run the following query with the (*) wild card in SQL Management studio without issues and I get the results I need:
SELECT Site, StreetAddress, City, State, Zip, PharmacyPhone, MDVersion,
InstallDate, SiteCodes, SiteNotActive, CloseDate, SiteNotes
FROM Sites
WHERE contains(site, '"ev*"' ) OR contains (StreetAddress, '"ev*"')
OR contains(city, '"ev*"')
BUT when attempting to run the code below in my c#, I do not get any results. What am I doing wrong? the array would contain the string 'ev*'. c# code:
private void btnSearch_Click(object sender, EventArgs e)
{
//Get the value from textbox
string keyword = txtboxKeyword.Text;
string[] words = keyword.Split(' ');
try
{
switch (words.Length)
{
case 1:
var select = "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)";
var conn = new SqlConnection(myconnstr);
SqlCommand cmd = new SqlCommand(select, conn);
cmd.Parameters.AddWithValue("@words0", words[0]);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
var commandbuilder = new SqlCommandBuilder(sda);
var dt = new DataTable();
sda.Fill(dt);
dataGridSites.ReadOnly = true;
dataGridSites.DataSource = dt;
dataGridSites.CurrentCell = null;
break;