【发布时间】:2009-11-24 02:27:20
【问题描述】:
我已通过 interop/COM 成功连接到 Microsoft Access 数据库。我需要将一些数据放入组合框并重新查询,以便显示信息。
// Create app
MsAccess.Application app = new MsAccess.Application();
// Open the database
app.OpenCurrentDatabase(
@"C:/Prog.mdb"
, false, "");
// Open the form
app.DoCmd.OpenForm("frmMain",
MsAccess.AcFormView.acNormal,
System.Reflection.Missing.Value,
System.Reflection.Missing.Value,
MsAccess.AcFormOpenDataMode.acFormPropertySettings,
MsAccess.AcWindowMode.acWindowNormal,
System.Reflection.Missing.Value
);
app.Forms["frmMain"]["ctrlCustList"] .. .
// This gets me the control instance validly..
// but do I put text in it?
app.DoCmd.Requery("ctrlCustList");
有没有办法通过互操作将文本发送到控件中? (我见过 GoToControl 但这是重点)但我仍然迷路并尝试谷歌搜索但没有太多运气..
【问题讨论】:
-
需要注意的一点:办公环境中不支持 Office 互操作。见support.microsoft.com/default.aspx/kb/257757
-
我认为 Jeffrey 的意思是“在服务器环境中”。
-
嗯.. 我正在访问网络驱动器上的 Access DB,但通过物理方式(在本地网络上)。
-
Jeffrey 引用的文章仅适用于尝试从 Web 应用程序(即 Web 服务器上)自动化 Office。
标签: c# ms-access combobox interop