Hey all i am getting an odd returned value in VB.net when i try to find the highest ID number in my table:
This is my VB.net code:
objConn = New MySqlConnection(product.strConnString)
objConn.Open()
strSQL = "SELECT MAX(id) FROM product;"
Try
objCmd = New MySqlCommand(strSQL, objConn)
dtReader = objCmd.ExecuteReader()
While dtReader.Read()
nextDBID = dtReader(0)
End While
objConn.Close()
objConn = Nothing
Catch ex As Exception
MsgBox("LoadProduct: " & ex.Message)
End Try
When i check the value of nextDBID it comes up as 39. However, there is no 39 in the database!
When i run that exact query in mySQL GUI i get this:
select MAX(id) from fivestar_range.product;
37
My id data field is this in the product table:
37
10
11
12
7
8
6
5
4
3
2
1
13
14
36
21
I even tried using this query:
SELECT id FROM product ORDER BY ID DESC LIMIT 1;
And i still end up with 39 in the VB.net but still 37 in mySQL GUI.
What’s going on that i’m overlooking?
Check your connection strings. You are likely looking at two different databases.