Good Morning,
I'm new to use a Telerik components and obviously I've have a problem.... :-D. So, the my problem is how to upload Documents (like DOC, Word, Excell ecc ecc) into a MS SQL Server with RadAsynUpload or RadUpload. In this moment I use FileUpload (MS VisualStudio 2010 Component) to uploading a documents, and this working fine but i would like use RadComponent to do this. So the VB code that I use is :
-- Upload --
Private Function uploadDoc(ByVal oFileUpload As FileUpload) As Boolean
Dim blnRet As Boolean = False
Dim oBinaryReader As New IO.BinaryReader(oFileUpload.PostedFile.InputStream)
Dim oByteArray As Byte() = oBinaryReader.ReadBytes(CInt(oFileUpload.PostedFile.ContentLength))
oBinaryReader.Close()
Dim nTkt As String = lbl_NumProt.Text
Dim TKTdb As New TKTdbDataContext
Dim oRequest = (From tbl In TKTdb.T_PROTO_INs Where (tbl.Num_Prot = nTkt) Select tbl).First
oRequest.AttachFilename = oFileUpload.FileName
oRequest.AttachContentType = oFileUpload.PostedFile.ContentType
oRequest.AttachFileSize = oByteArray.Length
oRequest.AttachData = oByteArray
Try
TKTdb.SubmitChanges()
blnRet = True
Catch ex As Exception
Throw New System.Exception(ex.Message)
End Try
Return blnRet
End Function
-- Download --
Shared Sub getOwnerAttachDoc(ByVal nTkt As String)
Dim blnRet As Boolean = False
Dim TKTdb As New TKTdbDataContext
Dim oRequest = (From tbl In TKTdb.T_PROTO_INs Where (tbl.Num_Prot = nTkt) Select tbl.AttachContentType, tbl.AttachData, tbl.AttachFilename, tbl.AttachFileSize).First
Dim Filename As String = HttpContext.Current.Server.UrlEncode(oRequest.AttachFilename)
Dim ContenType As String = oRequest.AttachContentType
Dim FileSize As String = oRequest.AttachFileSize
HttpContext.Current.Response.Clear()
HttpContext.Current.Response.ContentType = "application/octet-stream"
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=" & Filename & "")
HttpContext.Current.Response.AppendHeader("Content-Lenght", FileSize)
HttpContext.Current.Response.BinaryWrite(oRequest.AttachData.ToArray)
HttpContext.Current.Response.Flush()
HttpContext.Current.Response.End()
End Sub
Is possible to migrate that VB Code if I want use RadUploadControl or RadAsyncControl?
Thanks
Paolo
I'm new to use a Telerik components and obviously I've have a problem.... :-D. So, the my problem is how to upload Documents (like DOC, Word, Excell ecc ecc) into a MS SQL Server with RadAsynUpload or RadUpload. In this moment I use FileUpload (MS VisualStudio 2010 Component) to uploading a documents, and this working fine but i would like use RadComponent to do this. So the VB code that I use is :
-- Upload --
Private Function uploadDoc(ByVal oFileUpload As FileUpload) As Boolean
Dim blnRet As Boolean = False
Dim oBinaryReader As New IO.BinaryReader(oFileUpload.PostedFile.InputStream)
Dim oByteArray As Byte() = oBinaryReader.ReadBytes(CInt(oFileUpload.PostedFile.ContentLength))
oBinaryReader.Close()
Dim nTkt As String = lbl_NumProt.Text
Dim TKTdb As New TKTdbDataContext
Dim oRequest = (From tbl In TKTdb.T_PROTO_INs Where (tbl.Num_Prot = nTkt) Select tbl).First
oRequest.AttachFilename = oFileUpload.FileName
oRequest.AttachContentType = oFileUpload.PostedFile.ContentType
oRequest.AttachFileSize = oByteArray.Length
oRequest.AttachData = oByteArray
Try
TKTdb.SubmitChanges()
blnRet = True
Catch ex As Exception
Throw New System.Exception(ex.Message)
End Try
Return blnRet
End Function
-- Download --
Shared Sub getOwnerAttachDoc(ByVal nTkt As String)
Dim blnRet As Boolean = False
Dim TKTdb As New TKTdbDataContext
Dim oRequest = (From tbl In TKTdb.T_PROTO_INs Where (tbl.Num_Prot = nTkt) Select tbl.AttachContentType, tbl.AttachData, tbl.AttachFilename, tbl.AttachFileSize).First
Dim Filename As String = HttpContext.Current.Server.UrlEncode(oRequest.AttachFilename)
Dim ContenType As String = oRequest.AttachContentType
Dim FileSize As String = oRequest.AttachFileSize
HttpContext.Current.Response.Clear()
HttpContext.Current.Response.ContentType = "application/octet-stream"
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=" & Filename & "")
HttpContext.Current.Response.AppendHeader("Content-Lenght", FileSize)
HttpContext.Current.Response.BinaryWrite(oRequest.AttachData.ToArray)
HttpContext.Current.Response.Flush()
HttpContext.Current.Response.End()
End Sub
Is possible to migrate that VB Code if I want use RadUploadControl or RadAsyncControl?
Thanks
Paolo