shaqtus123
Technical User
I have a website that allows users to upload files. The uploaded file is managed using a FileUpload control. Inside the SQL database the file is inserted into a field called "Attachment" which has a data type of varbinary(MAX). Whenever I try to upload the file and insert it into the database by clicking the submit button, I get an error that basically saying something like "Cannot convert type varchar to varbinary(MAX)" Heres the code:
I don't see what the problem is here since I'm inputting data bytes of the file into the database... can someone please tell me what the problem is?
Code:
string cmdAnnouncement = "INSERT INTO Announcements [Attachment] VALUES ('" + fileUpload.FileBytes + "')";
SqlCommand cmd = db.executeSQL(cmdAnnouncement);
I don't see what the problem is here since I'm inputting data bytes of the file into the database... can someone please tell me what the problem is?