Click here to Skip to main content
15,891,204 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to select record in database
Posted
Comments
Santosh K. Tripathi 3-Mar-15 3:43am    
What you tried?
[no name] 3-Mar-15 3:45am    
What you tried ? are you beginner in asp.net ?

You should use an ORM (Object Relational Mapping) to access your database. Entity Framework is a good one, written by Microsoft.

There's an excellent article here to get you started:

http://www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/creating-an-entity-framework-data-model-for-an-asp-net-mvc-application[^]
 
Share this answer
 
For all records from the database you can use

SQL
select * from table_name


for a specific column you can use
SQL
select clumn_name from table_name 


for a specific column in a specific condition you can use a 'where' clause
SQL
select Column_name from table_name where column_name=value

like below example
SQL
select name from Customer where ID='1234567890'
 
Share this answer
 
Hi,
Select Command:
SQL
Select * From table_name --select all data directly from the table
Select Column_name from table_name --select particular column from the table

Ref:
Try this article : Insert, Update, Delete, Display Data in MySQL Using C#
 
Share this answer
 
Select Column_Name From Table Name

If We Want All Filed display in Table Just Use Following Query

select * From Table_Name
 
Share this answer
 
Did you try this code? It uses Web Pages version of the code to select a record from the database.

Works fine in .cshtml files of ASP.NET

C#
var db = Database.Open("database_name");
var record = db.Query("SELECT * FROM table_name WHERE column_name = @0", parameter);


Now wherever the value would be true, the result would be returned. A real example of this case is, WHERE UserId = @0", 20, to select the profile of user with UserId 20.
 
Share this answer
 

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