RSS Forums RSS

upload image in vb.net

Please support our VB.NET advertiser: DiscountASP.NET – 3 Months Free on VB.NET Web Hosting
Reply
Posts: 2
Reputation: venkat554 is an unknown quantity at this point 
Solved Threads: 0
venkat554 venkat554 is offline Offline
Newbie Poster

Re: upload images and store the location in a database

  #1  
Nov 28th, 2008
Originally Posted by quansah View Post
i want to upload files into a folder and store the relative loaction of that file in a database using php and mysql. help
how to upload image in vb.net.i need coding so please somebudy help me.

thank you
AddThis Social Bookmark Button
Reply With Quote  
Posts: 3,465
Reputation: peter_budo is a splendid one to behold peter_budo is a splendid one to behold peter_budo is a splendid one to behold peter_budo is a splendid one to behold peter_budo is a splendid one to behold peter_budo is a splendid one to behold peter_budo is a splendid one to behold 
Solved Threads: 412
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: upload image in vb.net

  #2  
Nov 28th, 2008
Post moved to BV.NET section
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote  
Posts: 650
Reputation: Teme64 is on a distinguished road 
Solved Threads: 106
Teme64's Avatar
Teme64 Teme64 is offline Offline
Practically a Master Poster

Re: upload image in vb.net

  #3  
Nov 28th, 2008
Dealing with images and databases is basically done with byte arrays.

Here's a one starting point with VB.NET code samples from my blog:
Convert image to byte array and vice versa
Save binary data to SQL Server with VB.NET

You may also try Daniweb's site search. I've answered the same or at least very similar question few times. A pretty good search phrase is "image SQL Server VB.NET" (without quotes).
Reply With Quote  
Posts: 143
Reputation: sierrainfo is an unknown quantity at this point 
Solved Threads: 9
sierrainfo sierrainfo is offline Offline
Junior Poster

Re: upload image in vb.net

  #4  
Dec 3rd, 2008
Reply With Quote  
Posts: 2
Reputation: venkat554 is an unknown quantity at this point 
Solved Threads: 0
venkat554 venkat554 is offline Offline
Newbie Poster

Re: upload images and store the location in a database

  #5  
Dec 4th, 2008
15. Dim connection As New SqlConnection("connection string here")
16. Dim command As New SqlCommand("UPDATE MyTable SET Picture = @Picture WHERE ID = 1", connection)
17.
18. Using picture As Image = Image.FromFile("file path here")
19. Using stream As New IO.MemoryStream
20. picture.Save(stream, Imaging.ImageFormat.Jpeg)
21. command.Parameters.Add("@Picture", SqlDbType.VarBinary).Value = stream.GetBuffer()
22. End Using
23. End Using
24.
25. connection.Open()
26. command.ExecuteNonQuery()
27. connection.Close()
Reply With Quote  
Posts: 650
Reputation: Teme64 is on a distinguished road 
Solved Threads: 106
Teme64's Avatar
Teme64 Teme64 is offline Offline
Practically a Master Poster

Re: upload image in vb.net

  #6  
Dec 4th, 2008
That works. If you have an existing row to update. If you want to insert a new one, the code changes a bit:
  1. 16. Dim command As New SqlCommand("INSERT INTO MyTable (Picture) VALUES (@Picture); SELECT @@IDENTITY AS 'Identity'", connection)
  2. 17. Dim ThisPictureID As Integer
  3. 26. ThisPictureID = CInt(command.ExecuteScalar())
Now ThisPictureID contains new ID.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Views: 1510 | Replies: 5 | Currently Viewing: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 2:23 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC