List:MySQL ODBC« Previous MessageNext Message »
From:Peter Carter Date:June 11 1999 2:40pm
Subject:Re: LONGBLOB and LONGTEXT and VB6 ... once more ...
View as plain text  
At 01:41 PM 6/11/99 +0100, you wrote:
>Hello all,
>
>I have got a problem writing data to a LONGBLOB or LONGTEXT field. VB6 does
>allways manage the field as non updateable ... is this a known error ... or
>isn't there any possibility writing LONGBLOB field with VB6 and MyODBC???
>
>TIA
>    Stephan Skusa
>
>Source:
>
>Private Sub OpenDatabase()
>    Dim Connect as String
>
>    Set RWS = DBEngine.CreateWorkspace("RemoteDB", User, PassWord,
>dbUseODBC)
>    Connect = "ODBC; DATABASE=MySQLBlobDB; UID=BlobUser; PWD=BlobPasswd;
>DSN=MySQLBlobDB;"
>    Set RDB = RWS.OpenDatabase("", dbDriverCompleteRequired, , Connect)
>End Sub
>
>Private Sub TransferBlob(ByRef FromField As Field, ByRef ToField As Field)
>  Const cCHUNKSIZE = 32768
>  Dim Offset As Long, TotalSize As Long, BlockSize As Long
>
>  TotalSize = FromField.FieldSize
>  If TotalSize < cCHUNKSIZE Then BlockSize = TotalSize Else BlockSize =
>cCHUNKSIZE
>  Do While Offset < TotalSize
>    ReDim Chunk(0 To BlockSize - 1) As Byte
>    Chunk = FromField.GetChunk(Offset, cCHUNKSIZE)
>    Call ToField.AppendChunk(Chunk)
>    Offset = Offset + cCHUNKSIZE
>    If TotalSize - Offset >= cCHUNKSIZE Then BlockSize = cCHUNKSIZE Else
>BlockSize = TotalSize - Offset
>  Loop
>End Sub
>
>Private Sub SaveRemoteBlob(ByVal id As Long, ByRef FromField As Field)
>  Dim RDS As Recordset
>
>  Set RDS = RDB.OpenRecordset("SELECT blobfield FROM blob_table WHERE blobid
>= " & CStr(id))
>  If Not RDS.EOF Then
>    Call RDS.Edit
>    Call TransferBlob(FromField, RDS.Fields("blobfield"))
>    Call RDS.Update
>  End If
>  RDS.Close: Set RDS = Nothing
>End Sub
>

Your problem is cursors, or your approach, or you did not know.

cursors : As your code stands, anything over a 2k packet or includes the
use of extended fetch will be disabled. This is normal, and you are stuck
with it under DAO. Microsoft insists that you use server side cursors to
cure this problem. MySQL does not support this. The probably never should.

your approach (aka the real world) : DAO is dead (or should be) for
updatable databases except access. Try using ADO. As it is newer, it is
more 'up to speed' on other database engines. If you know DAO now, it won't
be too much of an uphill battle.  The code equivilent of the above should
work in ADO.

you did not know : I wrote an online code vb wizzard that solves your
problem above. It's free and you do not even have to know how to code ADO.
It will do it for you. I don't remember why, but I use medium blobs. If
this is a concern, I may change it to long. The URL is in my signature and
listed under the links on the MySQL site.

 
---
Peter B. Carter (peterc@stripped)
Pager: 613-751-4660
http://www.pbc.ottawa.on.ca

Flames are a waste of cyberspace, don't bother.......

Thread
LONGBLOB and LONGTEXT and VB6 ... once more ...Stephan11 Jun
Re: LONGBLOB and LONGTEXT and VB6 ... once more ...Peter Carter12 Jun