如何向已创建的MsAccess数据库添加/更改属性?
这是我用于MsAccess创建的代码:
ADOX.Catalog catalog = new ADOX.Catalog();
catalog.Create(accessConnectionString);
//Create an Access connection and a command that we'll use
OleDbConnection accessConnection = new OleDbConnection(accessConnectionString);
OleDbCommand command = new OleDbCommand();
command.Connection = accessConnection;
//command.CommandType = CommandType.Text;
accessConnection.Open()
创建后我需要在其上设置/读取/更新一些属性。
有可能吗?
答案 0 :(得分:2)
经过一番研究,这是在msaccess数据库上设置属性的代码:
注意,为此,请添加此项(details):
using Microsoft.Office.Interop.Access.Dao;
var dbe = new DBEngine();
var db = dbe.OpenDatabase(@"C:\access\mydb.accdb");
//Initialize the properties
Dao.Property VERSION_PROPERTY = null;
//Fill them with values
VERSION_PROPERTY = db.CreateProperty("VERSION_PROPERTY", Dao.DataTypeEnum.dbText, "Hello There. I am property of the database", true);
//And append them
db.Properties.Append(VERSION_PROPERTY);