SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 beginner to sql, need help
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

balamreddy
Starting Member

2 Posts

Posted - 12/17/2010 :  13:59:18  Show Profile  Reply with Quote
hi
Help me in the above case

To print the max value on the label by getting it from database table.
Kindly the code to be used is C#.

webfred
Flowing Fount of Yak Knowledge

Germany
8768 Posts

Posted - 12/17/2010 :  14:07:13  Show Profile  Visit webfred's Homepage  Reply with Quote
I must say that you are very clear...


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

USA
7020 Posts

Posted - 12/17/2010 :  18:17:35  Show Profile  Reply with Quote
select max([value]) from [database table]


CODO ERGO SUM
Go to Top of Page

balamreddy
Starting Member

2 Posts

Posted - 12/18/2010 :  00:45:24  Show Profile  Reply with Quote
how can i get that max value into a label using c#


quote:
Originally posted by Michael Valentine Jones

select max([value]) from [database table]


CODO ERGO SUM

Go to Top of Page

Sachin.Nand
Flowing Fount of Yak Knowledge

2937 Posts

Posted - 12/18/2010 :  02:04:29  Show Profile  Reply with Quote
Use a command object of C#.Something like this

SqlCommand cmd = new SqlCommand(sql, conn);

where sql is the actual query to get the max value 
from the table and conn is the connection string.
Then set the value of the label to value returned from the command object.

label.text=Convert.ToString(cmd.ExecuteScalar)


PBUH


Edited by - Sachin.Nand on 12/18/2010 02:04:57
Go to Top of Page

GilaMonster
Flowing Fount of Yak Knowledge

South Africa
4507 Posts

Posted - 12/18/2010 :  03:08:27  Show Profile  Visit GilaMonster's Homepage  Reply with Quote
Seriously now. Read over what you posted and imagine that you know nothing about the scenario. Can you really figure out what's been asked? Why do you think we can?

--
Gail Shaw
SQL Server MVP
Go to Top of Page

DonAtWork
Flowing Fount of Yak Knowledge

2165 Posts

Posted - 12/22/2010 :  11:51:56  Show Profile  Reply with Quote
OP simply read some of Peter's replies where Peter did his mind reading act, and OP assumed OP could get an answer also.

http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspx
How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

For ultra basic questions, follow these links.
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000