线程thread,ODBC直接连接SQL
static void Update(thread t)
{
CCADOConnection connection;
str strSQL;
CCADOCommand Command;
CCADORecordSet RSet;
InventTable it;
SysOperationProgress simpleProgress;
int i,RecCount;
;
connection = new CCADOConnection();
Command = new CCADOCommand();
RSet = new CCADORecordSet();
connection.open("Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=DEV;Data Source=EKT-TS10");
Command.activeConnection(connection);
strSQL = "select count(*) as RecCount from InvenTtable";
Command.commandText(strSQL);
RSet = Command.execute();
RecCount = RSet.fields().itemName("RecCount").value();
strSQL = "Select top 1000 ItemId,NJ_MaterialType from InventTable";
Command.commandText(strSQL);
RSet = Command.execute();
While (!RSet.EOF())
{
ttsbegin;
select forupdate it where it.ItemId == RSet.fields().itemName("ItemId").value();
it.NJ_MaterialType = RSet.fields().itemName("NJ_MaterialType").value();
it.update();
ttscommit;
RSet.recordSet().movenext();
if(i mod 100 ==0)
print strfmt("Task: %1/%2", i,RecCount);
i++;
}
RSet.close();
connection.close();
}
//-------------------------------------------
static client void main(args args)
{
Thread t;
;
new ExecutePermission().assert();
NJ_MF_UpdateFromUAT_Thread::ShowProgressBar();
t = new thread();
t.run(classnum(NJ_MF_UpdateFromUAT_Thread),identifierstr(Update));
t.removeOnComplete(true);
}