Page 1 of 1

Please Help, can't read Blob data from MySql

Posted: Mon Nov 02, 2015 8:22 am
by Jannie
Hi All i have been trying to read a BLOB field from my Mysql database and display it in a datagrid.

I have loaded the blob field using MySql "load value from file" function when you right click on the BLOB field in the MySql result grid.

When i read the BLOB field i get funny characters like ÿØÿà.

see code below.

Code: Select all

on mouseUp
   get_database_data
   end mouseUp

command get_database_data  
   global gConnectionID, gDetailList
   
   put revOpenDatabase("MySQL","xxxxxxxxxxxx:3307","xxxxxxx","xxxxxxxx","xxxxxxx") into gConnectionID
   put "SELECT UserName, MyPicture From PotUser" into tDetails
   put revQueryDatabaseBLOB( gConnectionID, tDetails) into gDetailList  
   
   ConvertSQLCursorToArray gDetailList, theDataGridArray
   revCloseCursor gDetailList
   revCloseDatabase gConnectionID
   set the dgData of group "DataGrid1" to theDataGridArray   
end get_database_data

Code: Select all

command ConvertSQLCursorToArray pCursor, @pOutArrayA
	local i
	local theFields
	local theError
	
	## Get the names of all the columns in the database cursor
	put revDatabaseColumnNames(pCursor) into theFields
	if theFields begins with "revdberr," then
		put item 2 to -1 of theFields into theError
	end if
	
	if theError is empty then
	      
                put 0 into i
   
		## Loop through all rows in cursor
		repeat until revQueryIsAtEnd(pCursor)
   			add 1 to i
                          
			
			## Move all fields in row into next dimension of the array
   			repeat for each item theField in theFields
                             
                                  if theField = "MyPicture" Then
                                 
                                    
                                      
                                     put revDatabaseColumnNamed(pCursor, theField) into pOutArrayA[i][ theField ]
                                     
                                  else
                                       put revDatabaseColumnNamed(pCursor, theField) into pOutArrayA[i][ theField ]
                                  end if
			end repeat
			                  
               
			revMoveToNextRecord pCursor
		end repeat

                 
	end if
	
	return theError
end ConvertSQLCursorToArray

When i look at the value that is read into MyPicture it is ÿØÿà, should it not be the name of the Picture file, or am i missing something here?

Re: Please Help, can't read Blob data from MySql

Posted: Mon Nov 02, 2015 6:34 pm
by Klaus
Hi Jannie,
Jannie wrote:...
When i look at the value that is read into MyPicture it is ÿØÿà, should it not be the name of the Picture file?
No it shouldn't! :D
That is the actual binary data of that image, not the image name, and should not be put into a field, but rather
"put xxx into image xyz" in your "fillindata" handler of your datagrid.

Do you do something like this in that handler?


Best

Klaus