Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I need to open MSAccess report from VS2010 C# using CREATEINSTANCE

The problem is in docmd.openreport method

Please help!!

Type objType = Type.GetTypeFromProgID("Access.Application");
object objAccess = Activator.CreateInstance(objType);

objType.InvokeMember("OpenCurrentDatabase", System.Reflection.BindingFlags.InvokeMethod, null, objAccess, new object[] { strPath });

Object objRptName = sReportName;

objType.InvokeMember("Run", System.Reflection.BindingFlags.InvokeMethod, null, objAccess, new object[] { "ReportTest", "Testing Parameter to be printed on report"});;


Need help here
objType.InvokeMember("OpenReport", System.Reflection.BindingFlags.InvokeMethod, null, objDoCmd, new object[] { 2, moMissing, moMissing })
Posted
Updated 17-Dec-10 5:08am
v4
Comments
Abdul Quader Mamun 17-Dec-10 11:03am    
Use pre Tag for better reading.

1 solution

Why must you use Refelection? The more accepted way is to the use the Office Interops Office Primary Interop Assemblies[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900