其他分享
首页 > 其他分享> > HRESULT:0x80040213 OpenFromFile错误

HRESULT:0x80040213 OpenFromFile错误

作者:互联网

HRESULT:0x80040213 OpenFromFile错误

HRESULT:0x80040213 OpenFromFile错误

 

//根据Mdb文件获得workspace
        public static IWorkspace OpenMdbWorkSpace(String MdbFileName)
        {
            IWorkspaceFactory pWSFact = new AccessWorkspaceFactoryClass();

            IWorkspace pWor = pWSFact.OpenFromFile(MdbFileName, 0);
            return pWor;
        }

HRESULT:0x80040213 OpenFromFile

是MdbFileName文件不存在,正确的写法为:

 

  //根据Mdb文件获得workspace
        public static IWorkspace OpenMdbWorkSpace(String MdbFileName)
        {
            if (File.Exists(MdbFileName))
            {
                IWorkspaceFactory pWSFact = new AccessWorkspaceFactoryClass();

                IWorkspace pWor = pWSFact.OpenFromFile(MdbFileName, 0);
                return pWor;
            }
            else
            {
                return null;
            }
        }

 

   

标签:0x80040213,OpenFromFile,MdbFileName,IWorkspace,HRESULT,pWSFact,pWor
来源: https://blog.51cto.com/u_12139363/3018432