[Closed] dotnet database return values problem
hello! I am querying a sqlite database. The returned values are correct with the exception that the values returned are being appended with some string characters. For example, I have position Z and ID being returned here:
1180.13d0 160683L
345.175d0 176874L
345.186d0 176295L
1477.99d0 82286L
dotNetObject:System.DBNull 176191L
the position z is really 1180.13546 and the ID is 160683. Here is the part of the code that prints the values
for i = 0 to (readerObject.FieldCount - 1) do
format "% " precord[i]
format "
"
Does anyone know why this is happening?
d0 means double precision 64bit value, L means long integer value.
you could try casting them to float and integer, respectively.
Unless you need these values as a string, it shouldn’t a problem. It’s the formatting that adds the d0/L to the string, they’re not part of the actual value.
Thank you for the replies! Oddly enough the values are being returned with the d0 and L appended even when I remove formatting.
while readerObject.read() do (
local record = readerObject.item
append arr[1] record["engx"]
append arr[1] record["engy"]
append arr[1] record["engz"]
append arr[2] record["p2z"]
append arr[2] record["p2y"]
append arr[2] record["p2x"]
)
returns
#(306.02d0, 67.8741d0, 881.926d0, 306.02d0, 67.8741d0, 881.926d0, 625.894d0, 67.8861d0, 881.926d0...
This is expected behaviour. In what way is this a problem, or – what are you eventually doing with the values?
lo, the values are xyz coordinates / names / descriptions for objects in the scene.
EDIT: I was assuming the data was wrong based on the return without actually testing it first. Everything looks to be in order. MY BAD, thanks for the help!
I think it just looked wrong, instead of actually being wrong Because any time a long value is converted to a string, the L is appended. Same for the double precision float.