Guys I'm doing a query to DB using OLEDB with the following Command:
OleDbCommand maxCommand = new OleDbCommand("SELECT TOP 1 id AS maxId FROM `tableName` ORDER BY id DESC", AppConstants.OLEDBCONNECTION);
And then printing the result:
maxCommand.CommandType = CommandType.Text;
OleDbDataReader reader = maxCommand.ExecuteReader();
reader.Read();
Int64 maxId = Int64.Parse(reader["maxId"].ToString()) + 1;
The thing is I've tried using MAX()
and TOP 1
but both of them are returning 9999, when I know there are more than 10000 id
values.
Help please, if you need any additional information please leave a comment.