RanjiniPraba
asked on
saving the screen captured
Hi,
I have a function which captures the screen . now my problem is i need to store it in the database. i have aalready created the database. now how do i convert the picture(that i have captured) in to a bitmap and store it in the database. will the SavePicture method help.
Thanks
I have a function which captures the screen . now my problem is i need to store it in the database. i have aalready created the database. now how do i convert the picture(that i have captured) in to a bitmap and store it in the database. will the SavePicture method help.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Ups, link forgotten:
http://www.domaindlx.com/e_morcillo/scripts/showtip.asp?tip=pcarr
(sometimes the site is down but keep trying and you will not be dissapointed ;)
http://www.domaindlx.com/e_morcillo/scripts/showtip.asp?tip=pcarr
(sometimes the site is down but keep trying and you will not be dissapointed ;)
Yes, you can save the picture in the picturebox out using the SavePicture function, and then you can add it into a database using the ADO stream object. Assuming that you have ADO checked in the Project|References you can use this code (originally posed by Anthony - aperkins)
Sub AddImage(rs As ADODB.Recordset, ByVal FileName As String)
Dim stm As ADODB.Stream
Set stm = New ADODB.Stream
With stm
.Type = adTypeBinary
.Open
.LoadFromFile FileName
'Add a new record
rs.AddNew
'Stream the value into the field through the stream object
rs.Fields("ImageColumn").V alue = .Read
'Update the recordset
rs.Update
.Close
End With
Set stm = Nothing
End Sub
You could call this function as follows:
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
With rs
.Source = "Select * From Table1"
' you can do the same thing with an Ole column in Access
.ActiveConnection = "Provider=SQLOLEDB.1;User ID=userid;Initial Catalog=database;Data Source=sqlserver"
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.Open
AddImage rs, "c:\winnt\compaq.bmp"
.Close
End With
Set rs = Nothing
End Sub
Sub AddImage(rs As ADODB.Recordset, ByVal FileName As String)
Dim stm As ADODB.Stream
Set stm = New ADODB.Stream
With stm
.Type = adTypeBinary
.Open
.LoadFromFile FileName
'Add a new record
rs.AddNew
'Stream the value into the field through the stream object
rs.Fields("ImageColumn").V
'Update the recordset
rs.Update
.Close
End With
Set stm = Nothing
End Sub
You could call this function as follows:
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
With rs
.Source = "Select * From Table1"
' you can do the same thing with an Ole column in Access
.ActiveConnection = "Provider=SQLOLEDB.1;User ID=userid;Initial Catalog=database;Data Source=sqlserver"
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.Open
AddImage rs, "c:\winnt\compaq.bmp"
.Close
End With
Set rs = Nothing
End Sub
#listening
Hi!
Here's a file for you over the net:
Download...
http://www.vb-helper.com/HowTo/dbpict.zip
Description: Save and restore pictures in a database using ADO with AppendChunk and GetChunk (22K)
Download...
http://www.vb-helper.com/HowTo/dbimage2.zip
Description: Save and display images in a database (45K)
That's it!
glass cookie : )
Here's a file for you over the net:
Download...
http://www.vb-helper.com/HowTo/dbpict.zip
Description: Save and restore pictures in a database using ADO with AppendChunk and GetChunk (22K)
Download...
http://www.vb-helper.com/HowTo/dbimage2.zip
Description: Save and display images in a database (45K)
That's it!
glass cookie : )
Best not to save images to a database, why not save images to disk and simply record the image path/name into a field?
ASKER
hi, gallaghe ,this is not the answer which i expect.
hi others, i am yet to test all your comments, pleae give me sometime. thanks.
hi others, i am yet to test all your comments, pleae give me sometime. thanks.
thanks for "A" grade.
thanks for "A" grade.
Ranjini
Concerning your "reply" to my "comment". I didn't post a "answer" just wanted to "warn" you that saving images to a database table is not a very wise idea, even MS$ says so.
Do what you feel is right for you, but be forewarned.
Concerning your "reply" to my "comment". I didn't post a "answer" just wanted to "warn" you that saving images to a database table is not a very wise idea, even MS$ says so.
Do what you feel is right for you, but be forewarned.
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=21861&lngWId=1
Hope this helps.