On dimanche 31 août 2008, richard terry wrote: > snip.. > > > Did you look at the "PictureDatabase" example? It stores images files > > from disk into a database, and retrieves them. > > Thanks, yes I've done that overnight since your suggestion, and now have > this problem: > > My gambas code goes something like this and I've selected the png file to > load which has been passed to this routine as ImagePath. > > Public sub Save_Image(ImagePath as string) > > Dim img As Image > Dim pictureData As String > Dim sql As String > > img = Image.Load(ImagePath) ' Save temp image as png file > tempFile = Temp() & ".png" > img.Save(tempFile) > > > pictureData = File.Load(tempFile) 'reload as a string > > > At this point the pictureData string seems to be ok. > > I Then tried writing to the database: > > sql = "insert into temp_image(piccie)" > "values($$" > sql = sql & pictureData & "$$)" > > and got back this message: > > Query failed:ERROR: invalid byte sequence for encoding "UTF8":0x89 HINT: > This error can also happen if the byte sequence does not match the encoding > expected by the server, which is controlled by "client_encoding" > > Spent a couple of hours trawling the postgres help and looking up > client-encoding, pg_types etc etc, but with my limited brain power I got > nowhere > > Any idea's? > > > Regards > > Richard >
1) Check that piccie is actually a Blob field (did you create your database with the database manager?) 2) Do not forge your query yourself. Use the substitution parameters of the Exec command: DB.Exec("insert into temp_image(piccie) values(&1)", pictureData) Regards, -- Benoit Minisini ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user