Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have a Asp.Net Label CurrentUser.Label.
I have to show the SQL table that have the same value in SQL table Cell
A table contain username, name, mobile, email, phone.
In Asp.net i have a Label that contain Log In Username which user has log on the site.
How can i show the current user Name, Username, Phone, Mobile, Email on asp Page?
Posted
Comments
ZurdoDev 12-Jun-14 7:26am    
Where are you stuck? Use the SqlConnection and SqlCommand classes and the SqlDataReader to get the data from the database and then set the values.
ashvin.saini 21-Jun-14 3:11am    
It just print first row from sql table.

1 solution

Use ADO.NET classes to connect, create command and operate on data.

If the UserName is Unique in your Database, then you should query your Database with the following SQL query...
SQL
SELECT * FROM yourTableName WHERE UserName = @UserName

You need to pass parameter @UserName with Value as the Label Text.

Before all this, search how to work with ADO.NET and how to pass parameters for a query. You will get many examples on Google.
 
Share this answer
 
Comments
ashvin.saini 21-Jun-14 3:12am    
Yes but it is not working.
I am not sure what you have tried. Can you please show me the code snippet?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900