0

真的很奇怪...我正在尝试访问我的 win 8 应用程序中的 mdb 文件。这是我的简单代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.Common;
using System.Data.OleDb;

 string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Assets/File.mdb";
 string strSQL = "SELECT CF FROM Comuni WHERE Comune = '" + m_strComNasc + "'";
 OleDbConnection myConn = new OleDbConnection(strConn);
 OleDbCommand myCmd = new OleDbCommand(strSQL, myConn);
 myConn.Open();
 OleDbDataReader myReader = myCmd.ExecuteReader();
 if (myReader.Read())
      strConn = myReader.GetString(0);
 else
      strConn = "";

 myReader.Close();
 myConn.Close();

在解决方案资源管理器参考中,我完成了添加参考并选择了“C:\Program Files\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\System.Data.dll”...

这些是错误:

The base class or interface 'System.ComponentModel.Component' in assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' referenced by type 'System.Data.Common.DbConnection' could not be resolved    c:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.dll

The base class or interface 'System.ComponentModel.Component' in assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' referenced by type 'System.Data.Common.DbCommand' could not be resolved   c:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.dll

The base class or interface 'System.MarshalByRefObject' in assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' referenced by type 'System.Data.Common.DbDataReader' could not be resolved    c:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.dll
4

1 回答 1

1

您不能在 Metro (Windows Store) 应用程序中使用 ADO.Net。如果您查看.NET for Windows Store apps - supported APIs页面,您将看到System.Data命名空间不存在。

于 2013-04-21T16:47:32.410 回答