I need to read an attachment from an Access DB from within infopath.
This is the code that should work according an answer in this community, but it doesn't:
Database DAODataBase;
Workspace DAOWorkSpace;
DBEngine DAODBEngine = new DBEngineClass();
DAOWorkSpace = DAODBEngine.CreateWorkspace("wsInfopath", "Admin", "", WorkspaceTypeEnum.dbUseJet);
DAODataBase = DAOWorkSpace.OpenDatabase("D:\\_DEV\\Bunker database\\FrameAgreements.accdb", false, false, ";pwd=");
Recordset rstMain = DAODataBase.OpenRecordset(strSQL, RecordsetTypeEnum.dbOpenTable,RecordsetOptionEnum.dbReadOnly,false);
This is the error I get on the restMain instruction:
System.Runtime.InteropServices.COMException was unhandled by user code
HelpLink="jeterr40.chm#5003001"
Message="Invalid argument."
Source="DAO.Database"
ErrorCode=-2146825287
StackTrace:
at Microsoft.Office.Interop.Access.Dao.Database.OpenRecordset(String Name, Object Type, Object Options, Object LockEdit)
at Combined_form_b.FormCode.CTRL999_7_Clicked(Object sender, ClickedEventArgs e)
at Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent)
at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)
I tried setting different arguments but I keep getting the same error.
I ran out of ideas.
Help is appreciated since I'm stuck here.