3

upload file into sql server using asp.net and vb.net

view full story
linux-howto

http://www.daniweb.com – i found this code to upload a file into a sql database using the asp.net fileupload object (or vb) i found it here http://forums.asp.net/p/1480079/3451771.aspx i think it works, but i am a learning noob and have a question...where does my dbase info go in the code? 1. If FleUpload.HasFile Then 2. Dim fileName As String = Server.HtmlEncode(FleUpload.FileName) 3. Dim extension As String = System.IO.Path.GetExtension(fileName) 4. If (extension.ToUpper = ".JPG") Or (extension.ToUpper = ".GIF") Then 5. 6. '**** Resize image section **** 7. Dim image_file As System.Drawing.Image = System.Drawing.Image.FromStream(FleUpload.PostedFile.InputStream) 8. Dim image_height As Integer = image_file.Height 9. Dim image_width As Integer = image_file.Width 10. Dim max_height As Integer = 120 11. Dim max_width As Integer = 160 12. 13. 14. image_height = (image_height * max_width) / image_width 15. image_width = max_width 16. 17. If image_height > max_height Then 18. image_width = (image_width * max_height) / image_height 19. image_height = max_height 20. Else 21. End If 22. 23. 24. Dim bitmap_file As New Bitmap(image_file, image_width, image_height) 25. Dim stream As New System.IO.MemoryStream 26. 27. bitmap_file.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg) 28. stream.Position = 0 29. 30. Dim data(stream.Length) As Byte 31. stream.Read(data, 0, stream.Length) 32. '**** End resize image section **** 33. 34. 35. Dim myConn As New SqlConnection(ConfigurationManager.ConnectionStrings("cs").ConnectionString) 36. Dim mycmd As New SqlCommand("se_equipmentimages_insert", myConn) 37. mycmd.CommandType = CommandType.StoredProcedure 38. 39. mycmd.Parameters.AddWithValue("@equipment_id", id) 40. mycmd.Parameters.AddWithValue("@image_file", data) 41. 42. Try 43. myConn.Open() 44. mycmd.ExecuteNonQuery() 45. Catch ex As Exception 46. Finally 47. myConn.Close() 48. End Try 49. 50. Else 51. lblError.Text = "Please only upload .jpg or .gif files" 52. lblError.Visible = True 53. End If 54. Else 55. lblError.Text = "No file selected" 56. lblError.Visible = True 57. End If to wit... dbase name: mydBase table name: dBaseTable column names :fileOne, fileTwo, fileThree where in the code above does this go? also, how does this code work for multiple fileuploads at once? thanks james (General)