Показать сообщение отдельно
Старый 07.12.2007, 17:30   #1  
Blog bot is offline
Blog bot
Участник
 
25,644 / 848 (80) +++++++
Регистрация: 28.10.2006
C# and AX Development: Reading CSV files in AX (Axapta)
Источник: http://olondono.blogspot.com/2007/12...a-asciiio.html
==============

Reading CSV files in AX (Axapta)


AsciiIo x = new AsciiIo("C:\MyFilename.csv","R");
Container y;
CustTable ct;
CustAccount accountNum;
;

x.inRecordDelimiter('\r\n');
x.inFieldDelimiter(','); // Or other values like ; or \t

while (x.status() == IO_Status::Ok)
{
y = x.read();

if (conlen(y) == 3) // You can validate content here
{
accountNum = ConPeek(y, 1); // Index is one based (1-based) no zero based (0-based)

ttsbegin;

select forupdate ct
index hint AccountIdx
where ct.AccountNum == accountNum;

if (ct)
{
// Read and update fields
...
ct.update();
}
else
{
// Fill fields and insert record
...
ct.insert();
}

ttscommit;
}
}

Источник: http://olondono.blogspot.com/2007/12...a-asciiio.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.