Page 1 of 1

Blob-Commands & ODBC & MySQL = Strange results?

Posted: Thu Jan 20, 2011 9:14 pm
by Kiffi
Hello,

i have created a MySQL Database for checking
out the PB Blob-Commands:

Code: Select all

CREATE TABLE IF NOT EXISTS `myblobtest` (
  `myTinyBlob` tinyblob NOT NULL,
  `myMediumBlob` mediumblob NOT NULL,
  `myBlob` blob NOT NULL,
  `myLongBlob` longblob NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
after that i have created a ODBC-Connection (blobtest)
and inserted a bitmap into the 4 fields:

Code: Select all

DB = OpenDatabase(#PB_Any, "blobtest", "", "", #PB_Database_ODBC)

If DB
  
  If ReadFile(0, #PB_Compiler_Home + "Examples\Sources\Data\Drive.bmp")
    
    PictureLength = Lof(0)
    Picture = AllocateMemory(PictureLength)
    ReadData(0, Picture, PictureLength)
    CloseFile(0)
    
    SetDatabaseBlob(DB, 0, Picture, PictureLength)
    SetDatabaseBlob(DB, 1, Picture, PictureLength)
    SetDatabaseBlob(DB, 2, Picture, PictureLength)
    SetDatabaseBlob(DB, 3, Picture, PictureLength)
    
    If DatabaseUpdate(DB, "Insert Into myBlobTable (myTinyBlob, myMediumBlob, myBlob, myLongBlob) Values (?, ?, ?, ?)") = 0
      Debug DatabaseError()
    EndIf
    
    FreeMemory(Picture)
    
  EndIf
  
  CloseDatabase(DB)
  
EndIf
A look into pypMyAdmin shows: The Picture is inserted:

Image

Now i want to get the picture out of the database, but i get
strange results (here: DatabaseColumnType() and DatabaseColumnSize())

Code: Select all

DB = OpenDatabase(#PB_Any, "blobtest", "", "", #PB_Database_ODBC)

If DB
  
  If DatabaseQuery(DB, "Select myTinyBlob, myMediumBlob, myBlob, myLongBlob From myBlobTable")
    
    Debug DatabaseColumnType(DB, 0) ; -> 1 ( = #PB_Database_Long)
    Debug DatabaseColumnType(DB, 1) ; -> 1 ( = #PB_Database_Long)
    Debug DatabaseColumnType(DB, 2) ; -> 1 ( = #PB_Database_Long)
    Debug DatabaseColumnType(DB, 3) ; -> 1 ( = #PB_Database_Long)
    
    While NextDatabaseRow(DB)

      Debug DatabaseColumnSize(DB, 0) ; -> 255
      Debug DatabaseColumnSize(DB, 1) ; -> 16777215
      Debug DatabaseColumnSize(DB, 2) ; -> 65535
      Debug DatabaseColumnSize(DB, 3) ; -> -1
      
    Wend
    
    FinishDatabaseQuery(DB)
    
  EndIf
  
  CloseDatabase(DB)
  
EndIf
can anyone confirm this behaviour?

TIA & Greetings ... Kiffi (tested with MySQL Server 5.1.41 and MySQL ODBC Driver 5.1)

Re: Blob-Commands & ODBC & MySQL = Strange results?

Posted: Thu Jan 20, 2011 11:39 pm
by Marco2007