下面的代码导致错误。需要帮助才能成功执行它 [英] Below code resulting in error. need help to succesfully execute it

查看:82
本文介绍了下面的代码导致错误。需要帮助才能成功执行它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 using System;	using Extensibility;	using System.Runtime.InteropServices;    using System.Reflection;    using System.Windows.Forms;    using Microsoft.Office.Core;    using Access = Microsoft.Office.Interop.Access;        using System.Data;    using System.Data.Common;    using dao;

public void OnConnection(对象应用程序,Extensibility.ext_ConnectMode connectMode,对象addInInst,ref System.Array自定义){Microsoft.Office.Interop.Access.Application app =新的Access.Application(); try {// applicationObject =(Access.Application)application; applicationObject =(Access.Application)应用程序; addInInstance =(Microsoft.Office.Core.COMAddIn)addInInst; //此行使VBA能够回调到此对象。 // addInInstance.Object = this; // Microsoft.Office.Interop.Access.Application app = new Access.Application(); app =(Access.Application)应用程序; dao.Database AccessDB; dao.DBEngine DBEngine = new DBEngine(); System.Windows.Forms.MessageBox.Show(app.CurrentDb()名称。); AccessDB = DBEngine.OpenDatabase(app.CurrentDb()。Name); AccessDB.ExecuteSQL(" Create table TEST(SNOINT int,SRNO2 int)"); // applicationObject = application; // addInInstance = addInInst; //System.Windows.Forms.MessageBox.Show("Database Name" + applicationObject); if(connectMode!= Extensibility.ext_ConnectMode.ext_cm_Startup){OnStartupComplete(ref custom); catch(Exception ex){System.Windows.Forms.MessageBox.Show(" MyCOMAddin中的错误)); app.CloseCurrentDatabase(); }

public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { Microsoft.Office.Interop.Access.Application app = new Access.Application(); try { // applicationObject = (Access.Application)application; applicationObject = (Access.Application)application; addInInstance = (Microsoft.Office.Core.COMAddIn)addInInst; // This line enables VBA to call back into this object. // addInInstance.Object = this; // Microsoft.Office.Interop.Access.Application app = new Access.Application(); app = (Access.Application)application; dao.Database AccessDB; dao.DBEngine DBEngine = new DBEngine(); System.Windows.Forms.MessageBox.Show(app.CurrentDb().Name); AccessDB = DBEngine.OpenDatabase(app.CurrentDb().Name); AccessDB.ExecuteSQL("Create table TEST (SNOINT int, SRNO2 int)"); //applicationObject = application; // addInInstance = addInInst; //System.Windows.Forms.MessageBox.Show("Database Name" + applicationObject); if (connectMode != Extensibility.ext_ConnectMode.ext_cm_Startup) { OnStartupComplete(ref custom); } } catch(Exception ex) { System.Windows.Forms.MessageBox.Show("Error in MyCOMAddin"); app.CloseCurrentDatabase(); } }







推荐答案

告诉我们怎么样错误是什么???
How about telling us what the error is ???


这篇关于下面的代码导致错误。需要帮助才能成功执行它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆