image_code.doc ( 88k )
Number of downloads: 46hi i am new to vb6, i created the below code using vb6 as front end and Ms sql server as back end i want to store image file throught cdlg and then save it in sql data base img type by converting it into stream kindly suggest an easy way step by step in order to resolve this issue. i wll be very great full to u.... i need to submit this project this is only delayed for this.....hope you understand and reply soon.
waiting for your kind feedback.
Database name = warehouseporfile
Table name = Warehouseprofiledatabase
Field = uploadmapone
Type = image
Private Sub cmduploadsecuritymap_Click()
On Error GoTo a
cdlg.ShowOpen
'img1.Picture = LoadPicture(cdlg.FileName)
'FRMWHPROFILE.WHPROFILE.Fields("UploadMapone") = img1.Picture
'img1.Picture = Nothing
Label4.Caption = cdlg.FileName
Exit Sub
a:
End Sub
Private Sub cmdpreviewsecuritymap_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error GoTo a
'img1.Picture = LoadPicture(FRMWHPROFILE.WHPROFILE.Fields("UploadMapone"))
'img1.Picture = LoadPicture(cdlg.FileName)
img1.Picture = LoadPicture(Label4.Caption)
Exit Sub
a:
End Sub
Private Sub Label4_Click()
End Sub
Private Sub img1_Click()
End Sub
For saving image
Dim imagepath1 As String
imagepath1 = FRMWHPROFILE.Label4.Caption
FRMWHPROFILE.WHPROFILE.Fields("uploadmapone") = imagepath1
Call SaveImage1
Private Function SaveImage1()
Dim mStream As New ADODB.Stream
With mStream
.Type = adTypeBinary
.Open
.LoadFromFile "c:\"
WHPROFILE("uploadmapone").Value = .Read
WHPROFILE.Update
End With
Set mStream = Nothing
End Function
For showing image
Call LoadImage1
Public Function LoadImage1()
Dim mStream As New ADODB.Stream
With mStream
.Type = adTypeBinary
.Open
FRMWHPROFILE.img1.DataField = "uploadmapone"
'Set DataField....
'Set FRMWHPROFILE.img1.DataSource = WHPROFILE
'Set DataSource
'Set FRMWHPROFILE.WHPROFILE.Fields("uploadmapone") = FRMWHPROFILE.img1.Picture
'Show image into a cell of
'Microsoft FlexGrid
End With
Set mStream = Nothing
End Function