Click here to Skip to main content
15,848,157 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how can I Search the database with a plus sign?
I need search to database with c# in winforms like this
one+tow
Posted

You can build a string like this:
C#
string Sql = "SELECT * FROM table1 WHERE Name LIKE 'One+tow'";
 
Share this answer
 
Easy: use a parameterised query:
C#
using (SqlConnection con = new SqlConnection(strConnect))
    {
    con.Open();
    using (SqlDataAdapter da = new SqlDataAdapter("SELECT MyColumn1, MyColumn2 FROM myTable WHERE mySearchColumn = @SEARCH", con))
        {
        da.SelectCommand.Parameters.AddWithValue("@SEARCH", "one+two");
        DataTable dt = new DataTable();
        da.Fill(dt);
        myDataGridView.DataSource = dt;
        }
    }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900