Binary to SQL using ASP.NET
-
How can I upload Video files to my SQL SERVER database? A code expalme will be highly appreciated. thanks.
-
How can I upload Video files to my SQL SERVER database? A code expalme will be highly appreciated. thanks.
-
What is ntexg field? While at it I was trying something like this:
private void UploadFile() { if (fileUpload.HasFile) { string fileExt; fileExt = System.IO.Path.GetExtension(fileUpload.FileName).ToString(); //Response.Write(System.IO.Path.GetExtension(fileUpload.FileName).ToString()); //Response.Write(fileUpload.FileName Response.Write(fileExt); } } protected void Button1_Click(object sender, EventArgs e) { UploadFile(); }
It works for .rm, .img, .doc but when I try the same thing for .MPEG file and pages comes back with nothing! I mean it just dies:confused:, any one know why its doing that?
-
What is ntexg field? While at it I was trying something like this:
private void UploadFile() { if (fileUpload.HasFile) { string fileExt; fileExt = System.IO.Path.GetExtension(fileUpload.FileName).ToString(); //Response.Write(System.IO.Path.GetExtension(fileUpload.FileName).ToString()); //Response.Write(fileUpload.FileName Response.Write(fileExt); } } protected void Button1_Click(object sender, EventArgs e) { UploadFile(); }
It works for .rm, .img, .doc but when I try the same thing for .MPEG file and pages comes back with nothing! I mean it just dies:confused:, any one know why its doing that?
Here's the vb.net if you need me to translate, maybe I will. Make sure the sql datatype is image. Public Shared Sub SaveFile(ByVal FormID As Integer, ByVal FileName As String, ByVal File As Byte()) Dim conn As New SqlConnection(CStr(Current.Session("ConnectionString"))) Dim cmd As New SqlCommand() cmd.Connection = conn cmd.CommandType = CommandType.StoredProcedure cmd.CommandText = "dbo.uspSaveFile" AddFormIDParameter(cmd, FormID) Dim PrmFileImage As New SqlParameter("@File", SqlDbType.Image) PrmFileImage.Direction = ParameterDirection.Input cmd.Parameters.Add(PrmFileImage) PrmFileImage.Value = File Dim PrmFileName As New SqlParameter("@FileName", SqlDbType.VarChar, 100) PrmFileName.Direction = ParameterDirection.Input cmd.Parameters.Add(PrmFileName) PrmFileName.Value = FileName AddNetIDParameter(cmd) conn.Open() cmd.ExecuteNonQuery() conn.Close() End Sub 'Code to save file Dim len As Integer = File1.PostedFile.ContentLength Dim fileContents() As Byte = New Byte(len) {} File1.PostedFile.InputStream.Read(fileContents, 0, len) SaveFile(IntFormID, FileName, fileContents) "People who never make mistakes, never do anything." My Blog
-
Here's the vb.net if you need me to translate, maybe I will. Make sure the sql datatype is image. Public Shared Sub SaveFile(ByVal FormID As Integer, ByVal FileName As String, ByVal File As Byte()) Dim conn As New SqlConnection(CStr(Current.Session("ConnectionString"))) Dim cmd As New SqlCommand() cmd.Connection = conn cmd.CommandType = CommandType.StoredProcedure cmd.CommandText = "dbo.uspSaveFile" AddFormIDParameter(cmd, FormID) Dim PrmFileImage As New SqlParameter("@File", SqlDbType.Image) PrmFileImage.Direction = ParameterDirection.Input cmd.Parameters.Add(PrmFileImage) PrmFileImage.Value = File Dim PrmFileName As New SqlParameter("@FileName", SqlDbType.VarChar, 100) PrmFileName.Direction = ParameterDirection.Input cmd.Parameters.Add(PrmFileName) PrmFileName.Value = FileName AddNetIDParameter(cmd) conn.Open() cmd.ExecuteNonQuery() conn.Close() End Sub 'Code to save file Dim len As Integer = File1.PostedFile.ContentLength Dim fileContents() As Byte = New Byte(len) {} File1.PostedFile.InputStream.Read(fileContents, 0, len) SaveFile(IntFormID, FileName, fileContents) "People who never make mistakes, never do anything." My Blog
Thank you for your reply, the code works great for every other file but .MPG or .MPEG Do you have any Idea as to why i am unable to work with .MPG/.MPEG?? FYI: I am using ASP.NET 2.0
-
Thank you for your reply, the code works great for every other file but .MPG or .MPEG Do you have any Idea as to why i am unable to work with .MPG/.MPEG?? FYI: I am using ASP.NET 2.0
Ok well I suspected that the cause might be the size of file so I changed the executionTimeout limit to 900000 and even then I got this message: "Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. The statement has been terminated.0" Does any one how to use FTP instead of HTTP:confused:? I just read that in a thread and have no clue how to do that!!:wtf: You help will be highly appreciated. Thanks a lot for your replies.