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

Recommended Answers

Post moved to BV.NET section

Jump to Post

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

Jump to Post

All 5 Replies

Post moved to BV.NET section

15. Dim connection As New SqlConnection("connection string here")
16. Dim command As New SqlCommand("UPDATE MyTable SET Picture = @Picture WHERE ID = 1", connection)
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
25. connection.Open()
26. command.ExecuteNonQuery()
27. connection.Close()

That works. If you have an existing row to update. If you want to insert a new one, the code changes a bit:

16. Dim command As New SqlCommand("INSERT INTO MyTable (Picture) VALUES (@Picture); SELECT @@IDENTITY AS 'Identity'", connection)
17. Dim ThisPictureID As Integer
26. ThisPictureID = CInt(command.ExecuteScalar())

Now ThisPictureID contains new ID.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.