使用分布式调整对象(DTO)创建普和数据库
问题说明
我正在用C#(.NET 4.0)编写一个应用程序,该应用程序必须与另一个更旧的应用程序集成.要求的一部分是与使用Pervasive PSQL版本9的较旧程序集成.我问 DTO .
I am writing an application in C# (.NET 4.0) which has to integrate with another, much older application. Part of the requirement is to integrate with a much older program that uses Pervasive PSQL Version 9. I asked this question about accessing the database without having to install an ODBC DSN. Part of the answer (thanks very much) is that I need to create a database using DTO.
我已经使用COM interop来访问dto2.dll
COM库,并且已经阅读了示例,但是在创建数据库时遇到了问题.这是我正在使用的代码的摘要.
I've used COM interop to access the dto2.dll
COM library, and have read the samples, but I am having problems creating the database. Here is a summary of the code I'm using.
var session = new DtoSession();
var result = session.Connect("localhost", "", "");
Assert.AreEqual(dtoResult.Dto_Success, result);
testDB = new DtoDatabase {
Session = session,
Name = "Test1",
Ddfpath = @"C:\TEMP\DATA\DDF",
DataPath = @"C:\TEMP\DATA",
};
result = session.Databases.Add(testDB);
Assert.AreEqual(dtoResult.Dto_Success, result);
无论我为Name和path使用什么值,最终的Assert总是失败.错误代码为Dto_errDuplicateName
.如果我不包含Session
属性,则会得到不同的错误代码(7039).
No matter what values I use for the Name and paths, that final Assert always fails. The error code is Dto_errDuplicateName
. If I do not include the Session
property I get a different error code (7039).
有人成功做到了吗?我在做什么错了?
Has anyone done this successfully? What am I doing wrong?
正确答案
我相信您缺少DtoDatabase
对象的Flags
属性.我的档案库中包含以下代码,作为使用DTO添加数据库的示例.这段代码可能是在DTO首次发布时编写的,但是它可以工作,我唯一看到的区别是Flags
属性.
I believe you are missing the Flags
property of the DtoDatabase
object. I had the following code in my archive as an example of adding a database with DTO. This code was probably written when DTO was first released but it works and the only difference I can see is the Flags
property.
DtoSession session = new DtoSession();
dtoResult result;
result = session.Connect("localhost", "","");
if (result != dtoResult.Dto_Success)
{
Console.WriteLine("Error connecting. Error code: " result.ToString());
return;
}
DtoDatabase testDB = new DtoDatabase();
testDB.Name = "Test1";
testDB.DataPath = @"C:\DATA";
testDB.DdfPath = @"C:\DATA";
testDB.Flags = dtoDbFlags.dtoDbFlagNotApplicable;
result = session.Databases.Add(testDB);
if (result != dtoResult.Dto_Success)
{
Console.WriteLine("Error Adding. Error code: " result.ToString());
return;
}
Console.WriteLine("DB Added.");
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /reply/detail/tanhcfhgeh
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
检查邮件是否发送成功
it1352 07-25 -
Android微调工具-删除当前选择
it1352 06-20 -
希伯来语的空格句子标记化错误
it1352 06-22 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20