473,386 Members | 1,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

how to store photos in sql server and...

82
hi all,
i just want to know how to store photos in sql server 2000 and to retrieve it thro' vb
Nov 8 '06 #1
2 3007
Try this Code:.........

Expand|Select|Wrap|Line Numbers
  1.         Dim ms As New MemoryStream
  2.         Me.PictureBox1.Image.Save(ms, Me.PictureBox1.Image.RawFormat)
  3.  
  4.         Dim arrayImage() As Byte = ms.GetBuffer
  5.         ms.Close() ' Closes the Memory Stream
  6.  
  7.         Dim nStr As String = Me.Label1.Text.Substring(Me.Label1.Text.LastIndexOf("\") + 1)
  8.  
  9.         Dim strQuery As String = "INSERT INTO Pic(Name, Picture) VALUES(@Name, @Picture)"
  10.  
  11.         Dim objcommand As New SqlCommand(strQuery, Me.SqlConnection1)
  12.         With objcommand
  13.             .Parameters.Add(New SqlParameter("@Name", SqlDbType.NVarChar, 50)).Value = nStr
  14.             .Parameters.Add(New SqlParameter("@Picture", SqlDbType.Image)).Value = arrayImage
  15.         End With
  16.  
  17.         Me.SqlConnection1.Open()
  18.         objcommand.ExecuteNonQuery()
  19.         MessageBox.Show("Image Saved Into the DataBase")
  20.         Me.SqlConnection1.Close()
Nov 8 '06 #2
aaryan
82
hi,
thankz for your prompt reply. i will try it and report you abt that.
Nov 9 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Noozer | last post by:
I have a Windows 2000 server. My ASP application allows users to upload a photo for display to other users. Unfortunately everyones photos are different sizes. I'd like to resize the photo to 150px...
8
by: Nospam | last post by:
I'm a fairly experienced front end webdesigner without any knowledge of the backend or how to set up a store. I now have a potential job to develop a craft store for someone but will likely have to...
2
by: Ross | last post by:
Hi I have an application using asp.net that I am running on my PC. The web form has a text box where you can enter a name for a new Photo category then click on the button. The code is...
4
by: Dave G | last post by:
Firstly, apologies as this is not strictly an Access problem. I have a Access 2003 database containing records about people, and each person has 2 photos associated with the record. The photos...
2
by: Frankie | last post by:
Using SQL Server 2005 and .NET 2.0; I'm creating a Windows Forms application that will need to display photos of people, along with a bunch of information about each person. In a Web...
4
by: cheryl | last post by:
We are asked to create a website that can upload photos....Our website administrator must upload photos. His upoloaded photos must reflect on the users interface.. I dont know where and how to start...
2
by: =?Utf-8?B?TGlhbQ==?= | last post by:
My Photos folder opens automatically on startup and re-opens instantly when I close it. Occasionally a small black banner appears and disappears with the words "My Photos" on it. My Photos keeps...
0
by: damhotpepper | last post by:
How can I make a table that stores photos by location, date and cost?
1
by: jojo41300000 | last post by:
Hi, I am writing an application which will display the photos on the web pages. The photos are stored in the seperate machine but in the same LAN. First, when the user visit the web...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.