I have a database

LastBalance,AdmissionFee,ClassFee,Total,Received,Balance

Please tell me how can i get Last Balance from sql server

Recommended Answers

All 4 Replies

Try posting the work that you have done so far. If you are looking to be spoon fed the exact sql command to query your database, we are at least going to need to know a bit more about the database...

SELECT LastBalance FROM tablename WHERE condition_is_true

The condition will probably be something like ID=myID - it's something to identify the record by.

Take a look at the System.Data.SqlClient namespace, and search for some tutorials on using SQL with C#. There are plenty around.

//1. to get a total of LastBalace:
"SELECT SUM(LastBalance) FROM Students";

//2. to get the last LastBalance 
"SELECT MAX(LastBalance) FROM Students";

//3. to get a specifc lastBalance
"SELECT LastBalance FROM Students WHERE StudentID = @id";
//pass an integer value to @id parameter!
/use SqlCommand(of OleDbCommand for Access) class.

//And use SqlDataReader class to read the value!
commented: best answer +3

Yes,This is .Mitja You are the best programmer at daniweb.my problem has been solved by your query

"SELECT LastBalance FROM Students WHERE StudentID = @id";

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.