• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

使用分布式调整对象(DTO)创建普和数据库

用户头像
it1352
帮助1

问题说明

我正在用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?

正确答案

#1

我相信您缺少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
系列文章
更多 icon
同类精品
更多 icon
继续加载