Blob-Commands & ODBC & MySQL = Strange results?

Everything else that doesn't fall into one of the other PB categories.
User avatar
Kiffi
Addict
Addict
Posts: 1526
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Blob-Commands & ODBC & MySQL = Strange results?

Post 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)
Hygge
Marco2007
Enthusiast
Enthusiast
Posts: 648
Joined: Tue Jun 12, 2007 10:30 am
Location: not there...

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

Post by Marco2007 »

PureBasic for Windows
Post Reply