You need to sign in to do that
Don't have an account?
ppat
Please Someone Provide Batch Insert/update example!!
Hi All ,
I am new to salesforce and programming. I am trying to Batch insert/update accounts using C#. Can someone please provide me a sample code which will do batch insert or updates?? I have gone through the sample examples but it inserts only one record. I am not sure how to use querymore ,batchsize , queryoptions etc
My source is SQL server database.
Please help !!
a1.Name = "Account 1";
sforce.Account a2 = new sforce.Account();
a2.Name = "Account 2";
sforce.SObject [] objs = new sforce.SObject [] { a1, a2 };
sforce.SaveResult [] sr = binding.create(objs);
foreach (sforce.SaveResult s in sr)
{
if (s.sucess)
{
Console.WriteLine("new Id {0}", s.id);
}
else
{
Console.WriteLine("failed with error {0} {1}" s.errors[0].statusCode, s.errors[0].message);
}
}
update is the same except you call update instead of create.
Simon,
Thanks for the great code. Is there a way to do this where I don't have to name things A1, A2, etc? What I would essentially like to do is run a query, take the results of the query and set a custom date field so that I don't query this again. Not knowing how many records I am going to pull makes it both difficult and cumbersome to create a1,a2.etc. Also I assume that after the query that gets every record I should only be doing the update once. Can you help me with this? My C# is rusty. It seems like it should be pretty straight-forward. Then again . . . :)
Thanks,
Jeff