Looking for best practice for communicating between a C# application and an Access application

I have an Access application that will be invoking a C# app with a command line arg. I want the Access application to wait until the C# app is done doing its processing. Looking for the best method to make the Access application wait until valid data is passed back to it and how the data should be passed back to Access from C#.
LVL 6
dsulkarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David Johnson, CD, MVPOwnerCommented:
The best way is to code your C# app as an access plugin.using the Visual Studio tools for office otherwise you will have to within access start the c# app with the /wait parameter and use an intermediate file typically xml to pass data between the two. your app can work directly with the access database
0
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
There are a couple of ways to do what you want.   One would be to write a DLL in C# that is directly callable from VBA.

The other more generic approach is to call the C# app with Shell(), then include the code below for the Shell() process to finish.

Jim.

Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long

Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long

' Used for wait check.
Const STILL_ACTIVE = &H103
Const PROCESS_QUERY_INFORMATION = &H400


Public Sub WaitWhileRunning(lngHWnd As Long)

        Dim lngExitCode As Long
        Dim lnghProcess As Long

10      lngExitCode = STILL_ACTIVE
20      lnghProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, lngHWnd)

30      If lnghProcess > 0 Then
40        Do While lngExitCode = STILL_ACTIVE
50          Call GetExitCodeProcess(lnghProcess, lngExitCode)
60          DoEvents
70        Loop
80      End If

End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.