none
How i write like statement control textbox in c# RRS feed

  • Question

  • Problem

    How to write like statement  as bellow 

    I have text 1-2018-20112

    i need to select from database as like  -2018-

    2018 come from textbox

    so that how to write these statmnet from c#

    select * from trxheaderordersafe where mykey like '%'-textbox.text-'%'

    how to write these select correctly on c# please ?

    Monday, January 28, 2019 3:28 PM

All replies

  • public List<...> Search(string searchString)
    {
        ...
        SqlCommand command = new Command();
        command.Parameters.AddWithValue("@SEARCH","%-" + searchString + "-%");
        ...
    }

    Try it.
    Monday, January 28, 2019 3:33 PM
  • Hello,

    In regards to 2018, what are the rules to know to get that from 1-2018-20112 ?


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Monday, January 28, 2019 3:41 PM
    Moderator
  • Hi engahmedbarbary,

    What kind of database you are using, how do you connect your database, ado.net or entity framework?

    Best regards,

    Zhanglong


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, January 29, 2019 1:55 AM
    Moderator