-jenis fieldnya image
Dim bimg() As Byte
"Menampilkan Data pada Contol
Image "
Public Sub LoadImage()
On Error Resume Next
Dim RsP As ADODB.Recordset
Dim ImgS As Long
Dim OS As Long
Dim TmpPic As String
Const conCS = 100
TmpPic = App.path & "\tmpPic.bmp"
If Len(Dir(TmpPic)) > 0 Then
Kill TmpPic
End If
Dim f As Integer
Set RsP = Cn.Execute("select * from karyawan where nik='" & Adodc1.Recordset!nik & "'")
f = FreeFile
Open App.path & "\tmpPic.bmp" For Binary As #f
ImgS = RsP.Fields("photo").ActualSize
Pb1.Visible = True
If ImgS < 100 Then GoTo zz
Pb1.Max = ImgS
Pb1.Min = 0
Do While OS < ImgS
'DoEvents
Pb1.Value = OS
bimg() = RsP.Fields("photo").GetChunk(conCS)
Put #f, , bimg
OS = OS + conCS
Loop
zz:
Pb1.Visible = False
Close #f
Photo.Picture = Nothing
Photo.Picture = LoadPicture(App.path & "\tmpPic.bmp")
'Kill App.path & "\tmpPic.bmp"
End Sub
On Error Resume Next
Dim RsP As ADODB.Recordset
Dim ImgS As Long
Dim OS As Long
Dim TmpPic As String
Const conCS = 100
TmpPic = App.path & "\tmpPic.bmp"
If Len(Dir(TmpPic)) > 0 Then
Kill TmpPic
End If
Dim f As Integer
Set RsP = Cn.Execute("select * from karyawan where nik='" & Adodc1.Recordset!nik & "'")
f = FreeFile
Open App.path & "\tmpPic.bmp" For Binary As #f
ImgS = RsP.Fields("photo").ActualSize
Pb1.Visible = True
If ImgS < 100 Then GoTo zz
Pb1.Max = ImgS
Pb1.Min = 0
Do While OS < ImgS
'DoEvents
Pb1.Value = OS
bimg() = RsP.Fields("photo").GetChunk(conCS)
Put #f, , bimg
OS = OS + conCS
Loop
zz:
Pb1.Visible = False
Close #f
Photo.Picture = Nothing
Photo.Picture = LoadPicture(App.path & "\tmpPic.bmp")
'Kill App.path & "\tmpPic.bmp"
End Sub
Public Sub ImageS()
On Error Resume
Next
Dim IntNum As Integer
IntNum = FreeFile
Open strImgN For Binary As #IntNum
ReDim bimg(FileLen(strImgN))
Get #IntNum, , bimg
Close #IntNum
Dim IntNum As Integer
IntNum = FreeFile
Open strImgN For Binary As #IntNum
ReDim bimg(FileLen(strImgN))
Get #IntNum, , bimg
Close #IntNum
End Sub
"Menyimpan Data"
public sub Simpan
with Rs
.addnew
Call ImageS
If strImgN = "" Then
.Fields("Photo") = Null
Else
.Fields("Photo").AppendChunk bimg
End If
If strImgN = "" Then
.Fields("Photo") = Null
Else
.Fields("Photo").AppendChunk bimg
End If
end with
end sub
----- Original Message -----From: agus iwan supratmanSent: Thursday, March 23, 2006 4:19 PMSubject: [Programmer-VB] Mau Nanya Cara menyimpan file gambar ke database??Salam Kenal,Nama saya agus, saya pendatang baru di gruop ini, saya kerja di surabaya dan mau membuat database karyawan buat kantor. Saya mau nanya sama temen-temen, mohon bantuannya.Saya mau menyimpan data gambar (foto karyawan) ke database SQL Server 2000. Terus data foto tadi mau saya tampilkan menggunakan Crystal Report. Yang mau saya tanyakan :1. Bagaimana code VB untuk menyimpan file gambar tersebut ke database SQL Server 2000.2. Apa jenis format file untuk SQL Server nya.3. Kalau ada code tambahan di crystal report, bagaimana code nya. mohon bantuannya.Terima kasih atas bantuannya.AgusSurabaya
Apakah Anda Yahoo!?
Kunjungi halaman depan Yahoo! Indonesia yang baru!
Wahana Programmer Groups Links
<*> Untuk mengunjungi sponsor milis ini, klik link berikut:
http://wahanaprogrammer.net
<*> Untuk menghubungi owner milis ini, kirim email ke:
[EMAIL PROTECTED]
<*> Konsultasi pemrogramman bisa chat disini:
Yahoo! Messenger: wahanaprogrammer
YAHOO! GROUPS LINKS
- Visit your group "Programmer-VB" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
