MS Access interop - Data Import

℡╲_俬逩灬. 提交于 2019-12-03 21:20:49

Have you tried using VBA? You have more options configuring connections, and I'm sure I've used a timeout adjustment in that context in the past.

Also, I've generally found it simplest just to query a view directly (as long as you can either connect with a nolock, or tolerate however long it takes to transfer); this might be a good reason to create the intermediate temp table.

There might also be benefit to opening Acces explicitly in single-user mode for this stuff.

We've done this using ADO to connect to both source and destination data. You can set connection and command timeout values as required and read/append to each recordset.

No particularly quick but we were able to leave it running overnight

Jake Ginnivan

I have settled on a way to do this.

http://support.microsoft.com/kb/317114 describes the basic steps to start the access process.

I have made the Process a class variable instead of a local variable of the ShellGetApp method. This way when I call the Quit function for access, if it doesn't close for whatever reason I can kill the process explicitly.

app.Quit(Access.AcQuitOption.acQuitSaveAll);
if (!accessProcess.HasExited)
{
    Console.WriteLine("Access did not exit after being asked nicely, killing process manually");
    accessProcess.Kill();
}

I then have used a method timeout function here to give the access call a timeout. If it times out I can kill the access process as well (timeout could be due to a dialog window popping up and I do not want the process to hang forever. I got the timeout method here.

Implement C# Generic Timeout

I'm glad you have a solution that works for you. For the benefit of others reading this, I'll mention that SSIS would have been a possible solution to this problem. Note that the difference between SSIS and DTS is pretty much night and day.

It is not difficult to parameterize the export process, such that for each client, you could export a different set of views. You could loop over the lines of a text file having the view names in it, or use a query against a configuration database to get the list of views. Otherparameters could come from the same configuration database, on a per-client and/or per-view basis.

If necessary, there would also be the option of performing per-client pre- and post-processing, by executing a child process, or pacakge, if such is configured.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!