Since Xojo 2022R1 (same thing with R11) I get very strange result on negative numbers from MySQL Database. See below example
var db as MySQLCommunityServer = new MySQLCommunityServer
db.userName=“root”
db.Password=“xxxx”
db.databaseName=“testDB”
db.host = “127.0.0.1”
db.Connect
db.ExecuteSQL “DROP TABLE IF EXISTS test”
db.ExecuteSQL “CREATE TABLE test (id int, myValue double)”
db.ExecuteSQL “INSERT INTO test (id,myValue) VALUES (1,-5)”
db.ExecuteSQL “INSERT INTO test (id,myValue) VALUES (2,4)”
var data as RowSet = db.SelectSQL( “SELECT myValue FROM test”)
If data <> Nil and data.RowCount>0 Then
For Each row As DatabaseRow In data
var a as double = row.column(“myValue”).DoubleValue
var b as string = row.column(“myValue”).stringValue
var c as double = val(row.column(“myValue”).stringValue)
var d as string = str(val(b))
var e as Double=-50
msgbox str(a)+" “+b +” “+str(c)+” “+d+” "+str(e)
next
end if
Did you copy this verbatim? Is that really “-5” or “–5”?
If it’s the latter with the hyphen rather than the minus character and the column is text, then your results make sense because it’s just another character.
Datatype of myValue is double (Value confirmed to DOUBLE and -5 in sql database)
I did copy the result. I didn’t notice it’s the hypen character rather than minus character…
Could that be the reason why val(–5) return 0?
Then the big question is why database return –5 and not -5
If I change to
For i As Integer = 0 To data.RowCount-1
var a as double = data.column(“myValue”).DoubleValue
data.MoveToNextRow
next