upload a xls, doc, jpeg... to SQL DB with asp.net(vb code behind)
-
:wtf:I do not know c# so the code here on this site is just confusing is there any one who has examples of code on how to upload docs(xls, doc, txt) to a sql database using vb code behind TOTAL CONFUSED
If Not IsNothing(mabanniere.PostedFile) Then filtype = Right(mabanniere.PostedFile.FileName, 3) mabanniere.PostedFile.SaveAs("c:/temp/banniere." & filtype) Dim photo() As Byte = GetPhoto("c:/temp/banniere." & filtype) Me.SqlInsertsociete.Parameters("@BANNER").Value() = photo FileSystem.Kill("c:/temp/banniere." & filtype) End If Public Shared Function GetPhoto(ByVal filePath As String) As Byte() Dim fs As New System.IO.FileStream(filePath, System.IO.FileMode.Open, System.IO.FileAccess.Read) Dim br As New System.IO.BinaryReader(fs) Dim photo() As Byte = br.ReadBytes(fs.Length) fs.Read(photo, 0, fs.Length) br.Close() fs.Close() Return photo getphoto transform a file to a byte array. my upload control name is mabanniere regards