积极答复者
基于c#的AE二次开发----遍历数据库出错

问题
-
以下代码遍历一个Access数据库statescounties,它是一个工作空间对象
IWorkspaceFactory pAccessWorkspaceFactory;
pAccessWorkspaceFactory = new AccessWorkspaceFactoryClass();
//打开工作空间
IWorkspace pWorkspace;
pWorkspace = pAccessWorkspaceFactory.OpenFromFile(@"D:\temp\New Personal Geodatabase.mdb", 0);
IEnumDataset pEnumDataset;
pEnumDataset = pWorkspace.get_Datasets(esriDatasetType.esriDTAny);
IDataset pDataset;
pEnumDataset.Reset();
pDataset = pEnumDataset.Next();
while (pDataset != null)
{
MessageBox.Show(pDataset.Name);
pDataset = pEnumDataset.Next();
}
}
错误异常为:未处理 System.Runtime.InteropServices.COMException
Message="异常来自 HRESULT:0x80040228"
Source="ESRI.ArcGIS.DataSourcesGDB"
ErrorCode=-2147220952
StackTrace:
在 ESRI.ArcGIS.DataSourcesGDB.AccessWorkspaceFactoryClass.OpenFromFile(String fileName, Int32 hWnd)
在 bianli.Form1.button1_Click(Object sender, EventArgs e) 位置 C:\Documents and Settings\GISLab0\桌面\C#text\111\bianli\bianli\Form1.cs:行号 79
在 System.Windows.Forms.Control.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
在 System.Windows.Forms.Button.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.Run(Form mainForm)
在 bianli.Program.Main() 位置 C:\Documents and Settings\GISLab0\桌面\C#text\111\bianli\bianli\Program.cs:行号 17
在 System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
怎么改啊?????
答案
-
你好,
看下这篇KB文章 如何使用 Visual C# 自动化 Microsoft Access:
http://support.microsoft.com/kb/317114
本文演示了如何使用 Microsoft Visual C# 2005 或 Microsoft Visual C# .NET 自动化 Microsoft Access。其中的主题和示例代码说明了如何执行下列操作:- 在 Access 中打开数据库。
- 打印或预览 Access 报表。
- 显示和编辑 Access 窗体。
- 在打开受密码保护的数据库时或在用户级安全处于打开状态时避免出现对话框。
- 自动化 Access Runtime
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.- 已标记为答案 Riquel_DongModerator 2009年8月12日 5:32
全部回复
-
我晕,这个到底值解决还是没解决
Frank Xu Lei--谦卑若愚,好学若饥
专注于.NET平台下分布式应用系统开发和企业应用系统集成
Focus on Distributed Applications Development and EAI based on .NET
欢迎访问老徐的中文技术博客:Welcome to My Chinese Technical Blog
欢迎访问微软WCF中文技术论坛:Welcome to Microsoft Chinese WCF Forum
欢迎访问微软WCF英文技术论坛:Welcome to Microsoft English WCF Forum -
你自己回复了自己的问题,是解决了这个问题吗?
Frank Xu Lei--谦卑若愚,好学若饥
专注于.NET平台下分布式应用系统开发和企业应用系统集成
Focus on Distributed Applications Development and EAI based on .NET
欢迎访问老徐的中文技术博客:Welcome to My Chinese Technical Blog
欢迎访问微软WCF中文技术论坛:Welcome to Microsoft Chinese WCF Forum
欢迎访问微软WCF英文技术论坛:Welcome to Microsoft English WCF Forum -
http://forums.esri.com/上很多关于这个错误的讨论,去看看
Please mark the post answered your question as the answer, and mark other helpful posts as helpful.
Visual C++ MVP -
你好,
看下这篇KB文章 如何使用 Visual C# 自动化 Microsoft Access:
http://support.microsoft.com/kb/317114
本文演示了如何使用 Microsoft Visual C# 2005 或 Microsoft Visual C# .NET 自动化 Microsoft Access。其中的主题和示例代码说明了如何执行下列操作:- 在 Access 中打开数据库。
- 打印或预览 Access 报表。
- 显示和编辑 Access 窗体。
- 在打开受密码保护的数据库时或在用户级安全处于打开状态时避免出现对话框。
- 自动化 Access Runtime
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.- 已标记为答案 Riquel_DongModerator 2009年8月12日 5:32
-
我在engine10开发也在这里出错,一直“System.Runtime.InteropServices.COMException”类型的未经处理的异常在 *****.exe 中发生
其他信息: 异常来自 HRESULT:0x80040228我参照网上的方法,改了平台版本为x86,
程序入口添加了
bool bindOk= ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.EngineOrDesktop);
if (bindOk)Application.Run(new DigitalMapEditorMainForm());
许可也验证过的。但是它始终要出错。请问兽兽你是怎么解决的?