Click here to Skip to main content
15,910,878 members
Please Sign up or sign in to vote.
1.67/5 (2 votes)
How to get the max cell value in the database using c#?
Posted
Comments
lbazetto 28-Jul-13 21:29pm    
what is the context? a form? a table?
Gishisoft 28-Jul-13 21:31pm    
id|size|name
4 |10 | ben
5 |20 | zak
Gishisoft 28-Jul-13 21:32pm    
a simple table only. but i want to get the max value in a table. but use the dynamic code. because what if the table have more records.
lbazetto 28-Jul-13 21:33pm    
select max(id), max(size) from table
Gishisoft 28-Jul-13 21:34pm    
i want to code it in c#. how?

1 solution

You can write below code in your C# code behind file(.cs file). Execute this query with SQLDataReader.
C#
Select TOP 1 size from table_name ORDER BY size DESC

Take output in some variable and perform the action.

Regards..:laugh:
 
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