Picture User Control

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Richard Alvarez
    New Member
    • Apr 2011
    • 32

    Picture User Control

    Good day guys.. in the days i was busy creating this application that displays and saves an image file within the an access database. the field has an Ole Object property. is there a custom user control for this?


    Its a WinForms DTR application. just want to have a quick/easy way of saving and retrieving image files in access database. i know that i have to work it out as a blob but the prob is that i don't know how to do it.

    Just hoping if there is a fast way of saving and retrieving images in my access database..

    I have one but its in vb6.0 format. how can i convert it to vs .Net?

    thanks in advance
    Last edited by Frinavale; Oct 3 '11, 01:13 PM.
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    How are you "displaying " and "saving" the image?

    If you just want to store it in a database then connect to and insert/update the image into the database....

    Do you know how to use a database in your application?
    If you don't then check out this article on how to use a database in your application

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      I'm still not quite clear on what you're having problems with.
      You should be able to connect to the Access Database using an OleDBConnection. You should be able to retrieve data from the database using the OleDBDataReader. Aside from the oledb classes, the article that I posted earlier should outline what you need to do in order to connect to and retrieve data from a database.

      -Frinny

      Comment

      • Richard Alvarez
        New Member
        • Apr 2011
        • 32

        #4
        about connecting to database; its clear enough with me. the problem is the process of saving and retrieving image files in an ole object.
        also i want it to be in this king of format because uniformity in code is what i want to have in my works

        Code:
        If rsData.State = ConnectionState.Open Then rsData.Close()
                rsData.Open(String.Format("Select * from tblUsers where ID={0}", txtID.Text), DBConn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockPessimistic)
        
        with rsData
             .fields("Pic").value='something binary/blob"
             .update
        end with
        how could i use this format to save and retrieve image files of various formats in access database 2007

        Comment

        • Richard Alvarez
          New Member
          • Apr 2011
          • 32

          #5
          by the way rsData in here is declared as ADODB.Recordset and DBConn is declared as ADODB.Connectio n 'active connection'

          Comment

          • Frinavale
            Recognized Expert Expert
            • Oct 2006
            • 9749

            #6
            You could just try setting the PictureBox.Imag e with the binary data from the database...

            Otherwise you'll have to save the file type so that you can recreate the file.

            -Frinny

            Comment

            • Richard Alvarez
              New Member
              • Apr 2011
              • 32

              #7
              the user will browse for the image file that is to be inserted in the database.. how would i do that?

              Comment

              • Frinavale
                Recognized Expert Expert
                • Oct 2006
                • 9749

                #8
                Use the OpenFileDialog to let the user choose the file...then open it.

                Comment

                • Richard Alvarez
                  New Member
                  • Apr 2011
                  • 32

                  #9
                  yes of course that would be the one to use but we're already out of what the real problem is. How can I save and retrieve the image file within the ms access database?

                  Comment

                  • Rabbit
                    Recognized Expert MVP
                    • Jan 2007
                    • 12517

                    #10
                    You'll need to use the ADODB.Stream object to read and write binary data from/to a database. This link, http://support.microsoft.com/kb/258038, shows an example of how to do that. It's for SQL Server but you should be able to do the same thing with an access database.

                    Comment

                    • Richard Alvarez
                      New Member
                      • Apr 2011
                      • 32

                      #11
                      this is the thing that really need. Thanks a lot with your help guys. :D thank you so much.

                      Comment

                      • Rabbit
                        Recognized Expert MVP
                        • Jan 2007
                        • 12517

                        #12
                        No problem, good luck.

                        Comment

                        Working...