如果我尝试读取 Access 2013 数据库的架构,则会收到以下错误:
no read permission on 'MSysRelationships'
现在帮助告诉我
User-level security features are not available in Access apps, web databases,
or databases that use one of the new file formats (.accdb, .accde, .accdc, .accdr).
=> 如何读取该数据库的架构?
编辑 :
这是我在 Linqpad 中的代码:
var stringBuilder = new OleDbConnectionStringBuilder();
stringBuilder.Provider = "Microsoft.ACE.OLEDB.12.0";
stringBuilder.DataSource = @"C:\Recommendations.accdb";
using (var connection = new OleDbConnection(stringBuilder.ToString().Dump()))
{
connection.Open();
var schemaTable = connection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] {null, null, null, "TABLE"});
var sheetName = schemaTable.AsEnumerable().Select(row => row.Field<string>("TABLE_NAME")).First();
schemaTable.Dump();
string namesQuery = "SELECT DISTINCT szRelationship, szReferencedObject, szObject FROM MSysRelationships";
string namesQuery2 = string.Format("select Name, Age from [{0}]", "Users");
using (var command = new OleDbDataAdapter(namesQuery, connection))
{
var dataSet = new DataSet();
command.Fill(dataSet, sheetName);
dataSet.Dump();
}
connection.Close();
}