使用分布式调整对象(DTO)创建普及数据库 [英] Create Pervasive Database using Distributed Tuning Objects (DTO)

查看:189
本文介绍了使用分布式调整对象(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.");

这篇关于使用分布式调整对象(DTO)创建普及数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆