You must Sign In to post a response.
  • Category: .NET

    Retrieve data from tables (database) based on current user id into a label?


    I want to retrieve data from a table within my web application based on current user ID, and display that specific data in a label on a web form.

    For example, based on current user id, I want to retrieve the users 'FirstName' from a table called 'cvdetails' and then display that data in a label on a web form. Is it then possible to display other data (for example 'LastName') in a seperate label on the same web form?

    I'm having trouble in figuring out how to do this!

    Many Thanks for any help!
  • #764017
    Hi Luke,

    To implement the above task, you need to pass user I'd as a input parameter while retrieve data from database,

    Refer below sample query

    Select * from tablename where userid = @userid

    In above code @userid is input parameter, this you can pass from your code and fetch data from database using procedure

    Hope this will help you to achieve your requirement.

    Give respect to your work, Instead of trying to impress your boss.

    Blog :

  • #764054
    Hai Luke,
    Yes, you can get the data which you want and keep in the select statement which will be executed in the database. So once the query is executed, it will give you all the data and then you just need to assign it to the respective labels.
    Hope it will be helpful to you.

    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)

  • Sign In to post your comments