hey guys,,i recently got this code from robocr of this community,,i got this from another website,,im trying to use this in my project to link a photo,,but im not able to do that,,i get errors one by one when i try to run the code after importing the forms and modules into my project,,,can some one explain the function of each line in this code??? pls,,,,
my previous post was
http://www.daniweb.com/forums/newpostinthread236985.html?utm_source=vBMail&utm_medium=email&utm_campaign=ThreadUpdate

i need the explanation of each and every lines of the code mentioned in this page

http://www.vb-helper.com/howto_store_image_in_access_db.html

pls pls,,help me,,,

Private Sub Command1_Click()
'use common dialog control to allow user the select an image file
    With Dlgs
        .Filter = "(*.bmp;*.jpg;*.gif;*.dat;*.pcx)| " & _
            "*.bmp;*.jpg;*.gif;*.dat;*.pcx|(*.psd)|*.psd|(*.All " & _
            "files)|*.*"
        .ShowOpen

        If .FileName = "" Then Exit Sub

        FN = .FileTitle
        'Open File And Read as Binary (open the file selected by user)
        Open .FileName For Binary Access Read As #1

'create buffer in memory to hold the contents of the file
        FileBinary = Space(LOF(1))

'read the file into the buffer created and close the file
        Get #1, , FileBinary
        Close #1


        'Add File To DB
        rs.AddNew 'tell ado recordset object that you are adding a new record
        rs!Img_name = FN 'set a text field to the file name of the file selected by user
        rs!Image = FileBinary 'set a memo field with the contents of the buffer
        rs.Update 'tell the ado recordset that you want to save the new record

        'Refill List
        GetAllFiles 'unknown proceedure
    End With
End Sub

as for the second piece of code on that page...
query the database, check to see if record found, no>notify user, else>check to see if file exists and delete it if necessary, then save the contents of the memo field to the hard drive and use the load picture function to display the picture into an image control...

Good Luck

i get an error "type mismatch" with error no13 that highlights the line

set db = opendatabase("location",)

in the particular form where i've linked it,,,

pls help,,

i just now added microsoft active x blah blah in reference,,,from then i started getting this,,,,help me out,,,

Well the code provided on that page is DAO and not ADO. So you need to have a reference to DAO. Also, if that little snippit you gave is representive of your actual code, you should be getting an error because of the comma and blank thereafter (Compile Error: Expected Expression)

Good Luck

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.