1

I tried using the following code to store a file returned by openFileDialog to an attachment field ([photoattached] is name of the field) of a table (payment) in an Access database, but I got an "invalid argument" error at runtime. Can anyone tell me what the problem is?

byte[] imageContent = File.ReadAllBytes(openFileDialog.FileName);
var command = conn.CreateCommand();
command.CommandText = @"INSERT INTO payment (photoattached.FileName,photoattached.FileData) VALUES (@Filename,@File)";
command.Parameters.AddWithValue("@FileName", openFileDialog.FileName);
command.Parameters.AddWithValue("@File",imageContent );
command.ExecuteNonQuery();
Gord Thompson
  • 116,920
  • 32
  • 215
  • 418
masa79
  • 11
  • 1

0 Answers0