I'm trying to insert binary data into Attachment type field in Access from C# using OleDb provider.
Error: System.Data.OleDb.OleDbException: An INSERT INTO query cannot contain a multi-valued field.at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)at System.Data.OleDb.OleDbCommand.ExecuteReader()at SDKEnrollApp.Enroll.Run()
Code of the query:
com.CommandText = "INSERT INTO PersonFinger ([PersID], [FingerImage]) VALUES ('@PID', '@IMG')";
com.Parameters.AddWithValue("@PID", m_form.m_clientID);
com.Parameters.Add("@IMG", OleDbType.Binary,baImage.Length).Value = baImage;
dt = new DataTable();
dt.Load(com.ExecuteReader());
baImage
is a byte array.
Please, help me.
UPDATE
Now the code is:
com.CommandText = "INSERT INTO PersonFinger ([PersID], [FingerImage]) VALUES (@PID, @IMG)";
com.Parameters.AddWithValue("@PID", m_form.m_clientID);
com.Parameters.Add("@IMG", OleDbType.Binary).Value = baImage;
com.ExecuteNonQuery();
The problem still remains.
I've also tried to change field type to OLE object instead of Attachment. In this case the size of the saved file is always 12.
It is not about image file type. It is about byte array so I don't understand why it is marked as duplicate.