Saving Images - Problem 
Author Message
 Saving Images - Problem

The code below is from Microsoft at this link
http://www.*-*-*.com/ ;en-
us;Q316887

Problem:
2 records exist in a access database, that have fields
for Images. First save a iamge (.jpg) to the first
record. Then select another image to the second record.
The problem is that it saves the first picture that I
selected. I have tried to set everything to Nothing, but
nothing works.

Any help please.
Thanks

Private Sub File2OleDbBlob(ByVal SourceFilePath As String)
        Dim cn As New System.Data.OleDb.OleDbConnection
("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &
Application.StartupPath & "\Database\DVDMovieFile.mdb;")
        Dim cmd As New System.Data.OleDb.OleDbCommand
("UPDATE TBLMYMOVIES SET MOVIEPIC=? WHERE ID = " & CLng
(Mid$(gitmMySelMovie.Tag, 2)), gConn)
        Dim fs As New System.IO.FileStream
(SourceFilePath, IO.FileMode.Open, IO.FileAccess.Read)
        Dim b(fs.Length() - 1) As Byte
        fs.Read(b, 0, b.Length)
        fs.Close()
        Dim P As New System.Data.OleDb.OleDbParameter

b.Length, ParameterDirection.Input, False, 0, 0, Nothing,
DataRowVersion.Current, b)
        cmd.Parameters.Add(P)
        cn.Open()
        cmd.ExecuteNonQuery()
        cn.Close()
    End Sub



Sun, 03 Apr 2005 08:37:26 GMT  
 Saving Images - Problem
Well I fixed it. The problem was that I had modified the
code below to use my global OleDbCommand. For some reason
it does not like that and maybe I should re-thing the
global thing. Could anyone tell me why this is?

Quote:
>-----Original Message-----
>The code below is from Microsoft at this link
>http://support.microsoft.com/default.aspx?scid=kb;en-
>us;Q316887

>Problem:
>2 records exist in a access database, that have fields
>for Images. First save a iamge (.jpg) to the first
>record. Then select another image to the second record.
>The problem is that it saves the first picture that I
>selected. I have tried to set everything to Nothing, but
>nothing works.

>Any help please.
>Thanks

>Private Sub File2OleDbBlob(ByVal SourceFilePath As
String)
>        Dim cn As New System.Data.OleDb.OleDbConnection
>("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &
>Application.StartupPath & "\Database\DVDMovieFile.mdb;")
>        Dim cmd As New System.Data.OleDb.OleDbCommand
>("UPDATE TBLMYMOVIES SET MOVIEPIC=? WHERE ID = " & CLng
>(Mid$(gitmMySelMovie.Tag, 2)), gConn)
>        Dim fs As New System.IO.FileStream
>(SourceFilePath, IO.FileMode.Open, IO.FileAccess.Read)
>        Dim b(fs.Length() - 1) As Byte
>        fs.Read(b, 0, b.Length)
>        fs.Close()
>        Dim P As New System.Data.OleDb.OleDbParameter

>b.Length, ParameterDirection.Input, False, 0, 0,
Nothing,
>DataRowVersion.Current, b)
>        cmd.Parameters.Add(P)
>        cn.Open()
>        cmd.ExecuteNonQuery()
>        cn.Close()
>    End Sub
>.



Sun, 03 Apr 2005 09:06:59 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Problem Saving images from OLE to file

2. Saving image as jpeg problem

3. Problem Saving images from OLE to file (VB5)

4. Image Save Problem...

5. Image Save Problem

6. How to save my drawing graphic as image???i did load from image

7. I need to save an image from an image list to a file

8. Saving WANG image control images

9. Retrieve Bitmap of preview image - Summary Info - Save Preview Image

10. Save image in Sql Server and retrieve image from sqlserver to vb

11. Image combo problem - images are a little distorted

12. Images DB - Image Format Problem

 

 
Powered by phpBB® Forum Software