views:

314

answers:

3

I am trying to launch an existing MS Access database (Access 2010) from a Silverlight 4 OOB with elevated authorisation set. I keep getting an error. I can create a new Access application using the CreateObject keyword, but when I try to launch an existing one I get an error: "No object was found registered for specified ProgID."

Any help is appreciated. Here is the code I use:

string sMSAccess = "C:\\Users\\storltx\\Documents\\SL4Demo.accdb";
dynamic MSAccess = ComAutomationFactory.GetObject(sMSAccess);
MSAccess.Visible = true;
+2  A: 

I think you should pass "Access.Application" string to GetObject call. like this:

dynamic MSAccess = ComAutomationFactory.GetObject("Access.Application"); 
sarh
GetObject only works using the ProgID for previously activated objects. Silverlight appears to be limited to only ProgIDs (which is why the approach in the question fails). However this answer also won't work because it won't launch MSAccess and it doesn't indicate which database to load either.
AnthonyWJones
Thanks for your help on this question and previous ones. Great Job !!!
Tor Storli
A: 

OK, So how do I launch the Database from there? If I use dynamic MSAccess = ComAutomationFactory.GetObject("Access.Application"); I have a reference to Access but I still need to get a reference to the SL4Demo.accdb. In other words how do I continue the code?

Thanks!

:)=

Tor Storli
@Tor: This is not an answer you should post the above as a comment on @sarh's answer and then delete this answer. Please have a read through the FAQ. Stackoverflow is not like Newsgroups or forums that you may be accustomed to, with their time oriented threads of conversation.
AnthonyWJones
A: 

Try your code like this:-

string sMSAccess = "C:\\Users\\storltx\\Documents\\SL4Demo.accdb";
dynamic app = ComAutomationFactory.CreateObject("Access.Application");
app .Visible = true;
app.OpenCurrentDatabase(sMSAccess);
AnthonyWJones
Excellent. Works fine now!!!
Tor Storli