Getting error of data truncation of filesize column

I have a List Box that users can drag images onto.
The table then shows a thumbnail and certain metadata that we use to store in our database (pictured below)

Out of nowhere I’m starting to get an error saying:

At first I thought this was a database issue, so I went there first. Found out that column is set at Float(5,2)
NONE of the image sizes go beyond 5 digits. Out of the 11K images currently in that table, I’d say 80% of them are between 100 and 200mbs. With only a couple over 800. None even reach 1,000.
So that’s not the issue.
This is the code relevant to the error:

dim sFileSize as string = Str(Round(openfile.Length/1000000*10)*0.1)
    
//Add metadata to Listbox
for i as Integer = 0 to lstBoxImages.ColumnCount - 1
  Select Case lstBoxImages.ColumnTag(i)
  case "thumbnail"
    lstBoxImages.CellTag(lstBoxImages.LastIndex, i) = imageFrame
  case "ModFileName"
    lstBoxImages.Cell(lstBoxImages.LastIndex, i) = modFileName
  case "TotalSize"
    lstBoxImages.Cell(lstBoxImages.LastIndex, i) = dimensions
  case "kMDItemPhysicalSize"
    lstBoxImages.Cell(lstBoxImages.LastIndex, i) = sFileSize + "mb"
  else
    lstBoxImages.Cell(lstBoxImages.LastIndex, i) = results.Lookup(lstBoxImages.ColumnTag(i), "")
  end select
  
next

The above adds everything to the List Box
Now, when I hit “submit”, to submit the data to our database table, that’s when the error pops up.
This is the insert code for the database that has to deal with this specific column:

data.Column("filesize") = lstBoxImages.cell(i, 8).Left(7)

Anyone know why this error would be popping up?

Have you tried using DoubleColumn ?

What do you mean by that??

something like

data.DoubleColumn("filesize") = val( lstBoxImages.cell(i, 8).Left(7) )

since the code you have is trying to use a string to set the value of a column that should get what looks like a double

I tried your suggestion and get this error:
There is more than one item with this name and it’s not clear to which this refers.
data.DoubleColumn(“filesize”) = lstBoxImages.cell(i, 8).Left(7)
Which, in my opinion, is the absolute worst explanation of an error ever.

I take that back. I forgot to add val.
Your solution worked. Thank you so much!

I think you can mark it as the solution in the forums and others will see that the question is answered

1 Like