Hello,
I have a FileUpload control on my webform. I would like a user to be able to upload a file to the server. Is there any way to store this file in SQL Server 2005?
Thanks
ASPSQL66
Here is a piece of code from one of my projects.DataTable reqTable =new DataTable ("Request");SqlDataAdapter dataAdapter =new SqlDataAdapter ("Select * FROM Request", sqlconn);DataRow dataCurrentRow =null;SqlCommandBuilder builder =new SqlCommandBuilder (dataAdapter);builder.QuotePrefix ="[";builder.QuoteSuffix ="]";dataAdapter.Fill (reqTable);foreach (DataRow dataRowin reqTable.Rows){if ((long) dataRow["ID"] == requestID){dataCurrentRow = dataRow;break;}}dataCurrentRow["Attachment"] = fuAttachment.FileBytes;dataAdapter.Update (reqTable);
The above code updates the [Attachment] VARBINARY(MAX) field of the [Request] table where theID of the row matchesrequestID variable's value.fuAttachment is the FileUpload control on the page. I ripped off the exception handling and other error checking code.
Hope this helps
No comments:
Post a Comment