none
how to setup sql search command with user defined column(s)? RRS feed

  • Question

  • Hi guys,

    I have a complex question regarding how to write sqlcommand. my database has e.g. 5 columns, and I would like to let the user select which column to search and give the result based on the user searched column.

    If there is only one column this would be quite easy using "SELECT * FROM mydata.mytable WHERE name='"textBox1->text"'".

    But if I have for example 5 columns to define and in case the user can also NOT enter any value in one or more in the 5, the situation becomes more complex... If one would list all possibilities it would be 2 to the power of 5 which 32 situations with 32 possibility of sqlcommands..

    So, is there an easy way to do it??

    • Moved by Baron Bi Thursday, August 30, 2018 6:23 AM
    Tuesday, August 7, 2018 8:20 PM

All replies

  • Hi,

    thanks for posting here.

    >>I have a complex question regarding how to write sqlcommand. my database has e.g. 5 columns, and I would like to let the user select which column to search and give the result based on the user searched column.

    This forum is about c++ code issues. If you only have question about how to write sql command, please post on sql forum in technet. For example:

    https://social.technet.microsoft.com/forums/en-us/home?forum=sqlsearch&filter=alltypes&sort=lastpostdesc

    Your understanding and cooperation will be grateful.

    Best Regards,

    Baron Bi


    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.

    • Proposed as answer by Guido Franzke Wednesday, August 8, 2018 6:05 AM
    Wednesday, August 8, 2018 1:49 AM