您如何后折线数据库值值?
databasetypeenum
值列出了在这里。
您如何 late Bind 值?
目前,我正在传递文字整数:
64
dbversion40
128
fordbversion120
这是上下文中的当前代码:
public bool CompactAccessDatabase(string strSourceDB, string strTargetDB, string strPassword, int iMode)
{
try
{
// Get the DBEngine property
dynamic dbEngine = Activator.CreateInstance(Type.GetTypeFromProgID("DAO.DBEngine.120"));
// Build the DB connection string
string strDecryptedPassword = "";
string strDBConnectionString = "";
if(!string.IsNullOrEmpty(strPassword))
{
if (!DecryptDatabasePassword(strPassword, ref strDecryptedPassword))
{
SimpleLog.Log("DecryptDatabasePassword returned false");
}
strDBConnectionString = ";pwd=" + strDecryptedPassword;
}
int iOptions = 0; // To Compact
if (iMode == 1) // To MDB
iOptions = 64; // DatabaseTypeEnum.dbVersion40
else if(iMode == 2) // To ACCDB
iOptions = 128; // DatabaseTypeEnum.dbVersion120
// Perform the compact
dbEngine.CompactDatabase(strSourceDB, strTargetDB, "", iOptions, strDBConnectionString);
}
catch (Exception ex)
{
SimpleLog.Log(ex);
return false;
}
return true;
}
可以迟到固定枚举ID吗?还是最好使用硬编码值?
The DatabaseTypeEnum
values are listed here.
How do you late bind the values?
At the moment I am passing literal integers:
64
fordbVersion40
128
fordbVersion120
This is the current code in context:
public bool CompactAccessDatabase(string strSourceDB, string strTargetDB, string strPassword, int iMode)
{
try
{
// Get the DBEngine property
dynamic dbEngine = Activator.CreateInstance(Type.GetTypeFromProgID("DAO.DBEngine.120"));
// Build the DB connection string
string strDecryptedPassword = "";
string strDBConnectionString = "";
if(!string.IsNullOrEmpty(strPassword))
{
if (!DecryptDatabasePassword(strPassword, ref strDecryptedPassword))
{
SimpleLog.Log("DecryptDatabasePassword returned false");
}
strDBConnectionString = ";pwd=" + strDecryptedPassword;
}
int iOptions = 0; // To Compact
if (iMode == 1) // To MDB
iOptions = 64; // DatabaseTypeEnum.dbVersion40
else if(iMode == 2) // To ACCDB
iOptions = 128; // DatabaseTypeEnum.dbVersion120
// Perform the compact
dbEngine.CompactDatabase(strSourceDB, strTargetDB, "", iOptions, strDBConnectionString);
}
catch (Exception ex)
{
SimpleLog.Log(ex);
return false;
}
return true;
}
Is it possible to late bind the enum ids instead? Or is it best to use hard coded values?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需将其使用到int:
https://wwww.tutorialsteacher .com/articles/convert-int-to-enum-in-csharp
Just use cast it to int:
https://www.tutorialsteacher.com/articles/convert-int-to-enum-in-csharp