AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX: Программирование
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 07.08.2008, 16:50   #2  
oip is offline
oip
Axapta
Лучший по профессии 2014
 
2,564 / 1416 (53) ++++++++
Регистрация: 28.11.2005
Записей в блоге: 1
Цитата:
Execute a DTS package from X++

Recently someone asked how to execute a DTS package from X++. This was a great question and great timing because I had just recently completed a project that had to execute a DTS package. Below is the code that will allow you to do this:

X++:
protected void runDTSpkg()
{
    OdbcConnection cn;
    ResultSet rs;
    Statement s;
    str SQL;
    str temp;
;
 
    // Open up a connection to the Master Database, and execute the DTS package
    cn = this.CN("master");
    s = cn.createStatement();
    SQL = "xp_cmdshell 'dtsrun /SVSQL /Usomeuser /Pblocked /NPumpOverCS_SHIP'";
    rs = s.executeQuery(SQL);
    while(rs.next())
    {
        // Here you could see if an error occurs, or just use this loop to allow the DTS to finsih.
        temp = rs.getString(1);
        MMI_ErrLog::logError("PkgScoop",strfmt("%1",temp));
    }
}
So there are a couple of things I want to point out here. One is the actual statement used to do this:

xp_cmdshell 'dtsrun /SVSQL /Usomeuser /Pblocked /NPumpOverCS_SHIP'
The /S = Server Name, /U = User Name, /P = Password /N = Name of DTS package to execute. Notice that the parms are ran together with what your passing. This Must happen or you get an error.

Another thing I wanted to point out was that I do a while(rs.next()) {...} for the resultset. When executing a DTS package through the stored procedure xp_cmdshell results are returned telling you about what is going on. You can read these results and act on them, or do like I do and just put them into a general log table. Whatever you do though, you must preform the while(rs.next()) {...} so you can allow the DTS to fully finish before you continue to your next block of code that I assume would operate on the data that the DTS package brought in / manipulated, etc.
http://dynamics-ax.blogspot.com/2006...ge-from-x.html
Теги
документация

 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Ищу готовые базы Axapta locky_sql_ru DAX: Администрирование 25 28.02.2007 10:47
Размер базы Sergo DAX: Функционал 13 30.10.2006 12:17
Вопрос по журналу базы данных(лог) Hidden DAX: Функционал 2 21.09.2005 14:00
Отдельные базы, Компании или Фин. аналитика? YellowSubmarine DAX: Функционал 11 22.08.2005 15:19
Частичное списание стоимости ОС Anais DAX: Функционал 9 19.05.2004 05:33

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 21:40.