Create Address in CustTable


I want to create Address for a Customer in CustTable through code. I have written a simple job updating Address Table but it does not create anything. The job is the following:

static void Address(Args _args)

Address tAddress,sample;
CustTable tCustTable;
DirPartyTable tDirPartyTable;
While Select ForUpdate tAddress

tAddress.AddrTableId = tDirPartyTable.TableId;
tAddress.AddrRecId = tDirPartyTable.RecId;
tAddress.Name = “sample.Name”;
tAddress.Street = “sample.Street”;
tAddress.ZipCode = “sample.ZipCode”;
tAddress.City = “sample.City”;
tAddress.County = “sample.County”;
tAddress.State = “sample.State”;
tAddress.CountryRegionId = “sample.CountryRegionId”;


Please help.



That code is really suspicious. Why do you have that while select there at all, and why it doesn’t have any where condition?

What “does not create anything” means? Is insert() called? Do you get any error? Or is the record inserted to DB but you don’t see it in UI from the customer?