2019R2 picture problem

I’m converting from R1.1 to R2 and have been successful with the majority but I have a problem with replacing a picture in the database.
This problem is only when I SaveRow in a existing DB and not when I add a picture to the DB in a new row.
In R1.1 this works - rs.Field(“biopic”).PictureValue = p_bkCVR
In R2 I get a TypeMismatchException with - rs.ColumnAt(18).Value = p_bkCVR
I tried rs.ColumnAt(18).PictureValue = p_bkCVR and I get “Cannot assign a value to this property.
All pictures are png and they work everywhere else in both R1.1 and R2.
They can be called from the DB and displayed in a imagewell or canvas without problems.

Are you sure 18 is the right index???

RecordSet And DatabaseRow dont have the same base

Using indexes instead of the Column Name can lead to all kind of programmer errors

Yes 18 is correct. I use columnar(18) to get pictures from the DB. I save several items in the DB and only the picture is a problem.

Oh MY!
I hope you are NOT saying that “named fields” in a recordset have been deprecated?!!

… time passes, while I carefully fire up R2 so as to not disrupt my work

Whew! … just another stupid name change with no added benefit

RS.FIELD(“xxx”).stringvalue becomes RS.COLUMN(“xxx”).stringvalue (where RS changed from RECORDSET to ROWSET).

Please find me a DBA that calls a database record a ROW?

Databases contain TABLES… TABLES contain RECORDS… RECORDS contain FIELDS
Spreadsheets contains ROWS and COLUMNS

Avoid using indexes for fields, it’s a bad practice. Any change in the DB struct, or queries, can cause anything wrong including data corruption and a rocket going to the sun instead of mars.

Always in my top 5 for DB coding tips. I’ve had to debug code that’s had 30 to 40 fields query and once you get into code you have no idea (without looking it up) what field 17 is versus field 27.

If you must use indexes you should be using constants so you know what 17 and 27 is. That doesn’t solve the issue Rick has pointed out but at least it’s something that might help in finding why your data is all jacked up. Using the field name is so much safer.

Yes, don’t use indexes.

However: Getting back to @Kenneth Long 's original question:

What datatype is your p_bkCVR object?

If it is a Picture object, then you cannot set it by treating the .pictureValue of the field like a property. In R2, pictureValue is a method, and when you want to set the value, you need to pass in additional parameters: The picture format, the compression quality, and then the actual picture object.

See the docs for more info: https://documentation.xojo.com/api/databases/databasecolumn.html#databasecolumn-picturevalue

and for the LOVE of GOD… do NOT use spaces in a column name.

Maybe worst. Now Im Confused…

DatabaseColumn.PictureValue = SomePicture

Is this going to change all the fields in all the rows from that Column??

lol

I’d rather use “named fields” as I have always done, but the depreciation referred to ColumnAt(index) in r2.
I’m going back to “named fields” and see what happens.

Kimball L
p_bkCVR is a picture
DatabaseColumn.PictureValue sample code shows:
Set the picture value of a column in a RowSet:
// rs is a RowSet with an picture column called “Photo” and MyPhoto is a picture:
rs.EditRow
rs.Column(“Photo”).PictureValue = MyPhoto
rs.SaveRow

I don’t understand how to code this
DatabaseColumn.PictureValue(format As Picture.Formats, quality As Integer = Picture.QualityDefault, Assigns value As Picture)

Not trying , just typing here for you to do a research, but it seems something like:

// dc As DatabaseColumn

dc.PictureValue(Picture.Formats.PNG) = myPNGPicture

the deprecated text in the online manual guide to use the value property.
btw my emotion about xojo it seems it is always to be a green paprika …

[code]Dim p As Picture
p = test1 '<- a picture dropped into the ide contents

Dim db As New SqLiteDatabase(SpecialFolder.Documents.Child(“database.sqlite”))

db.Connect

Dim rs As RowSet = db.SelectSQL(“SELECT Id,Pic FROM Test WHERE Id = ?”,1)

rs.EditRow
rs.Column(“Pic”).Value = p.ToData(Picture.Formats.PNG,Picture.QualityDefault)
rs.SaveRow
[/code]

Markus R Thank you