win7 32bit+.net4.0
新手,请多指教~添加com引用Microsoft ADO Ext. 6.0 for DDL and Security
编译没有问题,执行如下代码时抛出异常,求指点
try
            {
                ADOX.Catalog _catalog = new ADOX.Catalog();
                _catalog.Create(GlobalEntity.connectionString(DBFileName));//这句话抛出异常了
                return _catalog;
            }
            catch (Exception ex)
            {
                throw ex;
            }System.Runtime.InteropServices.COMException (0x80040154): 没有注册类
   在 ClassLibrary.AccessDB.CreateDBFile(String DBFileName) 位置 D:\Documents\Visual Studio 2010\Projects\WinAppAIO\ClassLibrary\AccessDB.cs:行号 26
   在 ClassLibrary.AccessDB.initializationDB(String DBFileName, String TableName, Object[][] Columns) 位置 D:\Documents\Visual Studio 2010\Projects\WinAppAIO\ClassLibrary\AccessDB.cs:行号 59
   在 WinAppAIO.ImportData.btnSel_Click(Object sender, EventArgs e) 位置 D:\Documents\Visual Studio 2010\Projects\WinAppAIO\WinAppAIO\ImportData.cs:行号 60
   在 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.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

解决方案 »

  1.   

    原因已找到,connectionString写成了Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccess2007file.accdb;Persist Security Info=False;
    而未安装AccessDatabaseEngine导致的,安装之后不报这个错了。
    但是新的错误来了,
    Message:多步 OLE DB 操作产生错误。如果可能,请检查每个 OLE DB 状态值。没有工作被完成。
    Source:Provider
    StackTrace:   在 ADOX._Catalog.Create(String ConnectString)
    连接串换成Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;User Id=admin;Password=;解决了。
    具体的错误原因分析嘛就不知道了
      

  2.   

    Microsoft.ACE.OLEDB.12.0是连接access2007之后的数据库使用的
    Microsoft.Jet.OLEDB.4.0是连接access2003等数据库使用的。多步 OLE DB 操作产生错误。如果可能,请检查每个 OLE DB 状态值。
    应该是连接没打开吧
      

  3.   

    ADOX.Catalog.Create只需要传个connectionString就可以了,不需要手动打开连接吧,网上关于ADOX.Catalog.Create的帖子都是用mdb格式的
      

  4.   

    你是想要创建access2007之后的数据库?
      

  5.   

    参见
    http://dotnet.aspx.cc/file/Create-Access2010-Accdb-File.aspx
      

  6.   

    ADOX.Catalog cat = new ADOX.Catalog();
    cat.Create("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + accdb);
    你的文章里面就这么写没问题啊?我也是的啊,就是连接串多了个Persist Security Info=False;但是怎么就报错呢
      

  7.   

    你可以先在winform下测试下。
    注意安装 http://www.microsoft.com/downloads/zh-cn/details.aspx?familyid=c06b8369-60dd-4b64-a44b-84b371ede16d&displaylang=zh-cn
      

  8.   

    测试了下连接串多了Persist Security Info=False;这个就会报错:多步 OLE DB 操作产生错误。如果可能,请检查每个 OLE DB 状态值。没有工作被完成。如果按你的文章里面不加这句的话就没问题。
    这是什么情况啊?
      

  9.   

    http://download.csdn.net/detail/xianfajushi/4028787
      

  10.   

    2008Service 64位 IIS 发布的网站中用到了这个东西,然后就一只报找不到。。纠结死了