You need to sign in to do that
Don't have an account?

List exception
Must be something very silly.But i get an error like this
14:17:59:040 FATAL_ERROR System.QueryException: List has more than 1 row for assignment to SObject
for code below
List<Contact> mylist = new list<Contact> {[select id from Contact ]};
Anyone can spot anything?
Contact[] myList = [SELECT Id FROM Contact];
Use the syntax you are trying to use when a single object is used:
Contact[] myList = new Contact[] { new Contact() };
All Answers
Contact[] myList = [SELECT Id FROM Contact];
Use the syntax you are trying to use when a single object is used:
Contact[] myList = new Contact[] { new Contact() };
Try this :
List<Contact> mylist = new list<Contact> ([select id from Contact ]);
Thanks
Thanks Both.It works