Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

How To Store Images In SQL Database?

store image

  • Please log in to reply
4 replies to this topic

#1 Vivek_Joshi

Vivek_Joshi

    CC Lurker

  • Just Joined
  • Pip
  • 2 posts
  • Location:Bangalore , India
  • Programming Language:C, Java, C++, (Visual) Basic, PL/SQL, Visual Basic .NET
  • Learning:C#, PHP, Assembly, Bash

Posted 20 July 2012 - 12:26 AM

Hello Guys,
I have Designed a Commercial purpose software using VB.NET & SQL Server.. :nervous: I want to store images of the users in the Database... so how to upload images in the SQL Database.... :blushing: . All suggestions are appreciated.... :cool:





With Regards,
Vivek_Joshi
  • 1

#2 Orjan

Orjan

    CC Mentor

  • Moderator
  • 2918 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#

Posted 20 July 2012 - 01:34 AM

You need to have a field in the database having the "blob" field type where you store the image data
  • 0

I'm a System developer at XLENT Consultant Group mainly working with SugarCRM.
Please DO NOT send mail or PM to me with programming questions, post them in the appropriate forum instead, where I and others can answer you.


#3 Vivek_Joshi

Vivek_Joshi

    CC Lurker

  • Just Joined
  • Pip
  • 2 posts
  • Location:Bangalore , India
  • Programming Language:C, Java, C++, (Visual) Basic, PL/SQL, Visual Basic .NET
  • Learning:C#, PHP, Assembly, Bash

Posted 20 July 2012 - 03:14 AM

You need to have a field in the database having the "blob" field type where you store the image data


Sir,
I am using SQL server 2008.. there is no Datatype(or field type) "blob" is available.. i can use the Datatype "Image"..
But i found that the image must be converted into 'array of byte' in-order to store it in the database.. so can u help me with it..??


Yeah..,, the path of the image file can be stored in database.. but in-order to do so, i have to maintain a separate file-system to store the images... i want to store the Images in the database itself.
  • 0

#4 Orjan

Orjan

    CC Mentor

  • Moderator
  • 2918 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#

Posted 20 July 2012 - 04:09 AM

yeah, seems like image is the datatype in 2008.
to store it in a array of byte, you need to get the file size, then declare a variable of type byte array with size of the file

in c#, you would do
int[] i = new int[6];
to create a array of 6, then a byte array would be
byte[] i = new byte[filesize];

I'm not a VB programmer, but I hope these codes can help you dim your variable?
  • 1

I'm a System developer at XLENT Consultant Group mainly working with SugarCRM.
Please DO NOT send mail or PM to me with programming questions, post them in the appropriate forum instead, where I and others can answer you.


#5 kernelcoder

kernelcoder

    CC Devotee

  • Expert Member
  • PipPipPipPipPipPip
  • 990 posts
  • Location:Dhaka
  • Programming Language:C, Java, C++, C#, Visual Basic .NET
  • Learning:Objective-C, PHP, Python, Delphi/Object Pascal

Posted 20 July 2012 - 05:11 AM

Here is a tutorial on it though it is in C# but you can easily convert/port it to VB.NET.
  • 1





Also tagged with one or more of these keywords: store image

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download