hi guy's
how to show last (maximum) ID from table (access database) in label on the Form ...
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Aug 13, 2014, 2:06 AM EDT
Dipankar BiswasRank #992 · 2K reputationPosted Aug 12, 2014, 3:43 AM EDT
Ramesh MaruthiRank #937 · 2.2K reputationPosted Aug 12, 2014, 6:35 AM EDT
Hemant SrivastavaRank #581 · 4.2K reputationPosted Aug 12, 2014, 7:01 AM EDT
Ramesh, Last() works only in MS Access but not in SQL Server, MySQL, Oracle.
So the alternative of LAST() is :
SELECT TOP 1 column_name FROM table_name
ORDER BY column_name DESC;
If it helps you, please accept the answer.
Ramesh MaruthiRank #937 · 2.2K reputationPosted Aug 12, 2014, 7:04 AM EDT
VulpesRank #55 · 29.2K reputationPosted Aug 13, 2014, 12:16 AM EDT
ghasem dehRank #8,160 · 227 reputationPosted Aug 12, 2014, 7:37 PM EDT
first use this code :
con.Open();
string str;
str = "SELECT Num FROM Pic;";
com = new OleDbCommand(str, con);
OleDbDataReader reader = com.ExecuteReader();
reader.Read();
label1.Text = reader["Num"].ToString() + " Number";
butt display number 1 from table ... i want display last number !
now use this code :
con.Open();
string str;
str = "SELECT LAST(Num) FROM Pic;";
com = new OleDbCommand(str, con);
OleDbDataReader reader = com.ExecuteReader();
reader.Read();
label1.Text = reader["Num"].ToString() + " Number";
error in last line:
( Index Out Of Rang Exception Was Unhandled)
ghasem dehRank #8,160 · 227 reputationPosted Aug 13, 2014, 1:45 AM EDT
ghasem dehRank #8,160 · 227 reputationPosted Aug 13, 2014, 6:19 AM EDT