I have an ASP.Net web site I would like to allow the user to attach and upload files to. I would like to allow them to do this using the database.
I've figured most of this out. What I can't quite get is how to actually insert the file into the database.
I try to insert it as a varbinary array like so, but I always get an error that it can't be converted.
private int WriteToDB(string strName, string strType, ref byte Buffer)
SqlDataSource2.InsertCommand = "INSERT INTO [AttachmentTable] ([FileName], [FileSize], [ContentType], [FileData]) VALUES ('" + strName + "' ," + Buffer.Length + ", '" + strType + "', '" + Buffer + "')";