Hi when i am upload a csv to create Account and contact using Apex code. In the contact i need to give the acoount name which is a list. How to get accoutn id to contact.In the code i have bold the line contac.Kindly anyone tell how to resolve this.
My code:
accstoupload = new List<Account>();
contoupload = new List<Contact>();
opptoupload = new List<Opportunity>();
for (Integer i=1;i<filelines.size();i++)
{
String[] inputvalues = new String[]{};
inputvalues = filelines[i].split(',');
Account a = new Account();
a.Name = inputvalues[0];
accstoupload.add(a);
}
for (Integer i=1;i<filelines.size();i++)
{
String[] inputconvalues = new String[]{};
inputconvalues = filelines[i].split(',');
Contact con = new Contact();
con.AccountId = a.Id;
con.Lastname = inputconvalues[1];
con.Lastname_lead__c = inputconvalues[2];
contoupload.add(con);
}