none
vb.net sql and label RRS feed

  • Question

  • how can i write a vb.net 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......

    http://vb.net-informations.com/ado.net-dataproviders/ado.net-sqldatareader.htm

    http://vb.net-informations.com/ado.net-dataproviders/ado.net-datareader.htm

    if dr.HasRows  Then

       do something

    endif

    https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/retrieving-data-using-a-datareader

    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
    Moderator
  • 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:

    http://www.vb-tips.com/ExecuteScalarText.ASPX

    http://idealprogrammer.com/code-samples/vbnet-sqldatareader-source-code/

    Best Regards,

    Cherry


    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 Cor Ligthert Monday, March 19, 2018 9:10 AM
    Monday, March 19, 2018 1:36 AM
    Moderator