I am using MySQL server 3.51 database. I am insert/update image into database as follow;
VB Code:
Private Sub insertupdate_image() Dim MyStream As ADODB.Stream Set MyStream = New ADODB.Stream MyStream.Type = adTypeBinary MyStream.Open MyStream.Position = 0 Dim sTemp As String Dim MyData As Variant sTemp = "C:\SPAI_Temp\HMDaftar" & intHMDaftarID & ".jpg" If pPicture = 0 Then Exit Sub VB.SavePicture pPicture, sTemp MyStream.LoadFromFile sTemp Dim Rs As ADODB.Recordset Set Rs = New ADODB.Recordset query = "Select Gambar,HMDaftarID From t_HMGambar where HMDaftarID=" & intHMDaftarID Rs.Open query, db, , adLockPessimistic With Rs If .RecordCount > 0 Then .Fields!Gambar = MyStream.Read .Fields!HMDaftarID = intHMDaftarID .Update Else .AddNew .Fields!Gambar = MyStream.Read .Fields!HMDaftarID = intHMDaftarID .Update End If .Close End With MyStream.Close Set MyStream = Nothing End Sub
It is work well if I insert or update image that size below then 30Kb.
BUT, it is giving "Lost Connection to MySQL server during query" error if I insert or update image that the size above 30Kb.
What should I do?
Thanks




Reply With Quote