Click here to Skip to main content
15,881,832 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all Im trying to filter data but I seem to have a problem the user must only be able to filter data for a specific company for wich he is logged in for @companyName and then filter on user_name = @filterText
SQL
MySqlCommand sqlC = new MySqlCommand("select * from T_users where (Company_Name = @CompanyName) and (User_Name like '@filterText') ", myconfill);
Posted
Updated 18-Oct-12 5:08am
v2
Comments
joshrduncan2012 18-Oct-12 10:59am    
LIKEs require the "%" symbol otherwise they won't work in that desired format. Since you are using C#, you will also need the parameters.addwithvalue statements so the compiler can know what text you want to equate with the parameterization calls you have noted here.
mrDivan 18-Oct-12 11:05am    
Hi sorry yes I do use that my problem is in the logic the code works but if i Filter on say ex a the value of @filter can be more than one if there is more than one user with a username containing an a so then my statement never returns a value because the and doesn work but if n run the the statement without the where company_Name = @Company name then it does return results but it does then reutn results for the whole table and not just where comapnay name = @company Name
joshrduncan2012 18-Oct-12 12:28pm    
Can I see your entire code segment (not just what is shown here) as to what you are referring to? I can't infer from this.

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