I want to upload an image in the database using the following method:
public void upload(byte[] pic, string name)
{
using (DataClasses1DataContext context = new DataClasses1DataContext())
{
var result = (from usr in context.Tables
where usr.name == name
select usr).Single();
result.photo = pic;
context.SubmitChanges();
}
}
But I'm getting an error: "Cannot implicitly convert type 'byte[]' to 'string'".
The field "photo" in the database table "Tables" has varchar(MAX) type, I also tried Image and varbinary(MAX) types.
How can I make this work?