Page 2 of 2 FirstFirst 12
Results 41 to 54 of 54

Thread: Saving Images in Databases

  1. #41
    .NUT jmcilhinney's Avatar
    Join Date
    May 05
    Location
    Sydney, Australia
    Posts
    80,862

    Re: Saving Images in Databases

    Quote Originally Posted by moti barski View Post
    jmcilhinney what about the delete and update of the pictures
    The image is just data in the database like any other. You treat it exactly like any other data. If you have text or numbers in the database and you want to remove or replace them then you set that column of the row to either NULL or a new value. Exactly the same goes here. For instance, if you wanted to edit an image, you would query the database to get the current image, edit in your app, then save the new data, just as you would if you wanted to edit text.

  2. #42
    Fanatic Member
    Join Date
    Mar 09
    Posts
    755

    Re: Saving Images in Databases

    i think it could work with videos not only images
    time to amp up the beef

  3. #43
    .NUT jmcilhinney's Avatar
    Join Date
    May 05
    Location
    Sydney, Australia
    Posts
    80,862

    Re: Saving Images in Databases

    Quote Originally Posted by moti barski View Post
    i think it could work with videos not only images
    Data is data. It would work with anything that needs to be stored in binary form. I chose to write this thread about images because it was a such a common request.

  4. #44
    Junior Member
    Join Date
    Apr 11
    Location
    QLD, Australia
    Posts
    22

    Re: Saving Images in Databases

    very nice code, works great with my project.

    One thing i was wondering though, if a photo has other data stored against it, like x and y coords etc. Is this able to be extracted to a variable at the point of uploading the image?

  5. #45
    .NUT jmcilhinney's Avatar
    Join Date
    May 05
    Location
    Sydney, Australia
    Posts
    80,862

    Re: Saving Images in Databases

    Quote Originally Posted by Northy View Post
    very nice code, works great with my project.

    One thing i was wondering though, if a photo has other data stored against it, like x and y coords etc. Is this able to be extracted to a variable at the point of uploading the image?
    Certainly. Exactly how depends on the data format. That is beyond the scope of this thread though. You should start a new thread in the appropriate forum for more info.

  6. #46
    Fanatic Member
    Join Date
    Nov 10
    Posts
    772

    Re: Saving Images in Databases

    Hi John. I'm here first time to view this spectacular post, you provided. I'm not picking it completely, so starting from first please tell me that in the line No. 2, of vb.net code block, what is update mean there? Will I not insert the image by using insert query? If not, then how i will insert the entire form data, including image.

  7. #47
    .NUT jmcilhinney's Avatar
    Join Date
    May 05
    Location
    Sydney, Australia
    Posts
    80,862

    Re: Saving Images in Databases

    Quote Originally Posted by ADQUSIT View Post
    Hi John. I'm here first time to view this spectacular post, you provided. I'm not picking it completely, so starting from first please tell me that in the line No. 2, of vb.net code block, what is update mean there? Will I not insert the image by using insert query? If not, then how i will insert the entire form data, including image.
    The actual database is just ADO.NET, the same as any other ADO.NET. You retrieve, insert and update image data in exactly the same way as you do any other data. This thread is purely about the trick of using a MemoryStream to convert between an Image object and a Byte array. As far as ADO.NET is concerned, the Byte array is exactly the same as a String or Integer or any other data you move between your app and a database. Don;t try to make this into something difficult when it's not.

  8. #48
    Fanatic Member
    Join Date
    Nov 10
    Posts
    772

    Re: Saving Images in Databases

    Its all right, that its an only a trick of using a memoryStream..... right.

    Ok, but please tell me how do I insert image in database. If one is unknown about inserting image (for the first time) so he will definitely face so many problems, so how to solve them? Please John, You are the most senior person, for everyone in the forum. If you will not put the light in the dark roads of newbies, then how they will be professional. Pleasseeee, assist me guide me or refer to me some proper place, from where I can learn it from very beginning that how to insert image, in database, using vb.net.....

    I have very very solid hope from you, being so senior in this forum.

  9. #49
    PowerPoster techgnome's Avatar
    Join Date
    May 02
    Posts
    21,659

    Re: Saving Images in Databases

    I'm not sure what more you need...
    1) create a sql statement that updates the table, setting the field with binary data... be sure to use a parameter...
    2) add the parameter to the parameters collection
    3) Put the bits of the image into the parameter.... an array of bytes works, as does a stream... could be a memory stream... a file stream... doesn't matter... as long as it's a stream....
    4) execute it...

    you're over thinking it... it's not rocket science... you want an example, post #1 has a very good example... your other post on the same thing, dday provided a LINE by LINE analysis of how it works...


    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.-I also subscribe to all threads I participate, so there's no need to pm when there's an update.*
    *Proof positive that searching the forums does work: View Thread *
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *
    * Use Offensive Programming, not Defensive Programming. * On Error Resume Next is error ignoring, not error handling(tm).
    "There is a major problem with your code, and VB wants to tell you what it is.. but you have decided to put your fingers in your ears and shout 'I'm not listening!'" - si_the_geek on using OERN

  10. #50
    Fanatic Member
    Join Date
    Nov 10
    Posts
    772

    Re: Saving Images in Databases

    I've done all what you wanted me to do, but its now giving me an exception of file not found, in my another post...

  11. #51
    .NUT jmcilhinney's Avatar
    Join Date
    May 05
    Location
    Sydney, Australia
    Posts
    80,862

    Re: Saving Images in Databases

    Quote Originally Posted by ADQUSIT View Post
    I've done all what you wanted me to do, but its now giving me an exception of file not found, in my another post...
    It should be fairly obvious what the problem is if the exception tells you that it can't find the file you specified.

  12. #52
    Fanatic Member
    Join Date
    Nov 10
    Posts
    772

    Re: Saving Images in Databases

    but everything is working all right John, then why i'm having error.

  13. #53
    Fanatic Member
    Join Date
    Nov 10
    Posts
    772

    Re: Saving Images in Databases

    Hmmmmm. Hi John, I have performed all the things correctly, by the great help of all my respected members. I followed your code as well in my problem and i finally got achievement. But there is a little problem, your code, makes me able to select the same image, while i want different image everytime. the path which i have given in code:

    Using picture As Image = Image.FromFile("C:\Documents and Settings\ADQUSIT\Desktop\dwn.jpg")
    It does not select any other picture? please assist me that how to select different pictures?

  14. #54
    .NUT jmcilhinney's Avatar
    Join Date
    May 05
    Location
    Sydney, Australia
    Posts
    80,862

    Re: Saving Images in Databases

    Quote Originally Posted by ADQUSIT View Post
    Hmmmmm. Hi John, I have performed all the things correctly, by the great help of all my respected members. I followed your code as well in my problem and i finally got achievement. But there is a little problem, your code, makes me able to select the same image, while i want different image everytime. the path which i have given in code:



    It does not select any other picture? please assist me that how to select different pictures?
    That has nothing to do with the topic of this thread.

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •