aku bingung gimana caranya buat load image dari databse (access).
nah data type-nya=text. ini source code nya.
===ini form1====
(mengambil data dari database)
Public Sub getImgeFromDB(rsCoba As ADODB.Recordset, ByVal stFLDName
As String, ByVal stFileName As String)
On Error GoTo ErrHdir
'Dim Conn As ADODB.Stream
Set Conn = New ADODB.Connection
Conn.Type = adTypeBinary
Conn.Open
If FileExist(stFileName) Then
Conn.LoadFromFile stFileName
rsCoba.Fields(stFLDImage).Value = Conn.Read
End If
End Sub
Private Sub Command1_Click()
Form2.Show
End Sub
Private Sub Command2_Click()
Adodc1.RecordSource = "select nama,coment,pic from baru where
nama='" & Text1.Text & "'"
Adodc1.Refresh
If Not Adodc1.Recordset.EOF Then
Text1.Text = Adodc1.Recordset.Fields("nama")
Text2.Text = Adodc1.Recordset.Fields("coment")
LoadPictureFromDB = True
Image2 = Adodc1.Recordset.Fields("pic")
Else
MsgBox "Data tidak ada,,coba lagi...", vbOKOnly +
vbInformation, "Data"
End If
Adodc1.Recordset.Close
End Sub
===ini form 2===
'ADD IMAGE TO DATABASE
Public Sub PutImgToDB(rsCoba As ADODB.Recordset, ByVal stFLDImage As
String, ByVal stFileName As String)
'Dim Conn As ADODB.Stream
Set Conn = New ADODB.Connection
Conn.Type = adTypeBinary
Conn.Open
Conn.Write rsCoba.Fields(stFLDName).Value
Conn.SaveToFile stFileName, adSaveCreatorOverWrite
If FileExist(stFileName) Then
Conn.LoadFromFile stFileName
rsCoba.Fields(stFLDImage).Value = Conn.Read
End If
End Sub
'SIMPAN FILE
Private Sub Command1_Click()
If (Text1.Text = "") Or (Text2.Text = "") Then
MsgBox "Data Anda Belum Lengkap,,lengkapin dulu deh...", , "save"
Else
With Adodc1.Recordset
!nama = Text1.Text
!coment = Text2.Text
!pic = Form1.Image1.Picture
.Update
End With
validasi (2): Text1.Enabled = True
Command1.Enabled = False: Command2.Enabled = True
End If
Text1.Text = "": Text2.Text = ""
Text1.Enabled = True: Text2.Enabled = True
Form2.Hide
Form1.Show
End Sub
Private Sub Text1_Change()
Adodc1.RecordSource = "select * from baru where nama ='" &
Text1.Text & "'"
Adodc1.Refresh
With Adodc1.Recordset
If .PageCount <> 0 Then
Text2.Text = !coment
validasi (2): Command1.Enabled = False
Command2.Enabled = True
Else
Adodc1.RecordSource = "select * from baru"
Adodc1.Refresh: Adodc1.Recordset.AddNew
validasi (0): validasi (1): Command1.Enabled = True
Command2.Enabled = True
End If
End With
End Sub
tolong ya?
Untuk berhenti berlangganan kirim email kosong ke : [EMAIL PROTECTED]
Bagi terjangkit virus lokal, zip virus tersebut
dan kirim ke [EMAIL PROTECTED], kami
akan membuat removalnya untuk anda.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/indoprog-vb/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/indoprog-vb/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/