function DTOTest()
string szCompName,szUser,szPassword, svString;
object objDTO;
number result,nResult;
string Desc;
object m_DtoDatabase;
object m_DtoDSN;
begin
nResult = AskText ("Local Computer Name", "", szCompName);
if (nResult = NEXT) then
nResult = AskText ("Admin User", "", szUser);
endif;
if (nResult = NEXT) then
nResult = AskText ("Password", "", szPassword);
endif;
//nResult = SdShowAnyDialog("DTO INformation","",12033,0);
if (nResult = NEXT) then
set objDTO = CreateObject("DTO.DtoSession.1");
result = objDTO.Connect(szCompName,szUser,szPassword);
if (result != 0) then
MessageBox("Error Connecting", INFORMATION);
else
// now that we're connected, let's create a DBN and DSN
set m_DtoDatabase = CreateObject("DTO.DtoDatabase.1");
m_DtoDatabase.DataPath = INSTALLDIR;
m_DtoDatabase.DdfPath = INSTALLDIR;
m_DtoDatabase.Name = "DTO Test from IS";
m_DtoDatabase.Flags = 0;
try
nResult = objDTO.Databases.Add(m_DtoDatabase);
if (nResult = 0) then
//DBN Created, now let's create the DSN
set m_DtoDSN = CreateObject("DTO.DtoDSN.1");
MessageBox ("Added DBN.",INFORMATION);
m_DtoDSN.DBName = m_DtoDatabase.Name;
m_DtoDSN.Description = "DTO DSN Created through IS7";
m_DtoDSN.OpenMode = 0; //sets normal open mode
m_DtoDSN.Name = "IS7 DTO DSN";
nResult = objDTO.DSNs.Add(m_DtoDSN);
MessageBox ("DSN Add completed.",INFORMATION);
if (nResult = 0) then
//DSN Created.
else
result = NumToStr (svString, nResult);
MessageBox("Error Creating DSN. " ^ svString,SEVERE);
endif;
else
//DBN not Created.
nResult = NumToStr (svString, result);
SetDialogTitle ( DLG_MSG_INFORMATION, "Error Creating DBN" );
MessageBox("Error creating DBN: " ^ svString ,SEVERE);
endif;
catch
Desc = "In Catch. " + Err.Description;
SetDialogTitle ( DLG_MSG_INFORMATION, "Error Description" );
MessageBox(Desc, SEVERE);
endcatch;
endif;
result = objDTO.Disconnect;
//set objDTO = nothing;
endif;
end;