c# - How to re write Office Automation Code -
vs 2008 / c# / ms 2007
i have saved import feature in access database invokes odbc connection. instead of depending on in-built saved import feature, trying rewrite feature in c# call odbc connection import data ms access database.
i not able call connection string saved in access database calls odbc drivers. keep failing .. !!
access.application access1 = new access.application(); try { string ssalisburyaccessdb = server.mappath("app_data/database1.mdb"); access1.opencurrentdatabase(ssalisburyaccessdb, true, null); // drop existing table data access1.docmd.deleteobject(access.acobjecttype.actable, "plans"); access1.docmd.deleteobject(access.acobjecttype.actable, "price"); // run saved import access1.docmd.runsavedimportexport("testodbc"); // close database access1.closecurrentdatabase(); // quit ms access access1.quit(access.acquitoption.acquitsaveall); response.write("successful"); } catch (exception ex) { response.write(ex.message); }
to me seems using automation in iis (server.mappath... ans response.write...) ?
if case not supported ms - see http://support.microsoft.com/default.aspx?scid=kb;en-us;q257757#kb2
reasons several: starting security , not ending fact office never built such server usage scenario...
i don't understand why not using odbc c# instead of ms access ? perhaps show more surce code or exception/error message... ?
edit - after long discussion (see comments):
if need access faircom db add using system.data.odbc;
, try
odbcconnection dbconnection2salisbury = new odbcconnection("dsn=salisbury;dbq=s:\;codepage=1252;"); dbconnection2salisbury.open();
after able use ado.net query etc. faircom db i.e. odbccommand
, odbcdatareader
etc.
for information see http://msdn.microsoft.com/en-us/library/system.data.odbc.aspx
sample code see http://www.easysoft.com/developer/languages/csharp/ado-net-odbc.html
Comments
Post a Comment