Tuesday, July 28, 2009

How to upload an movie file to sql server in varbinary (80000) field from asp.net page using c#?

how to upload an movie file to sql server in varbinary (80000) field from asp.net page using c#

How to upload an movie file to sql server in varbinary (80000) field from asp.net page using c#?
Use a file upload box from HTML to select it. Then get the file selected in the Upload box using the following command:


System.IO.MemoryStream ms = new System.IO.MemoryStream(this.FileUpload1....





Then, once you have the memory stream, you need to get an array of bytes from it:


byte[] blob = ms.ToArray();





Finally, when you are passing this to your database, just use a stored procedure and then pass the blob to its intended variable.





Good luck!


No comments:

Post a Comment