none sql and label RRS feed

  • Question

  • how can i write a where if a sql query has results than it will display a text box and a button
    Saturday, March 17, 2018 4:26 AM

All replies

  • Well if you're talking MS SQL Server......

    if dr.HasRows  Then

       do something


    Saturday, March 17, 2018 6:27 AM
  • Hello,

    You need to be specific with what you want. 

    For instance, in the question title you mention a label while in the text of the question the wording sounds like you want to create a text box and a button. If this is correct then where should the text box go, how do you expect to interact with it and the same for the button.

    If the above is incorrect supply details along with what type of database and even perhaps the SQL statement so we can better understand what you want to achieve. 

    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

    Saturday, March 17, 2018 9:01 AM
  • Hi imran1234,

    One way is to use sqlcommand.ExecuteScalar, another is use to sqlcommand.ExecuteReader,

    about the detailed example, you can take a look the following code:

    Best Regards,


    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

    • Proposed as answer by Cor Ligthert Monday, March 19, 2018 9:10 AM
    Monday, March 19, 2018 1:36 AM