class Vote
{
public static void DoneVote(DataTable table)
{
string siteUrl = "...";
try
{
using (SPSite site = new SPSite(siteUrl))
{
using (SPWeb web = site.OpenWeb())
{
foreach (DataRow row in table.Rows)
{
SPList list = web.Lists.TryGetList("ListName");
if (list != null) {
SPListItem itemToAdd = list.AddItem();
itemToAdd["Title"] = "DA0000";
itemToAdd["IdProject"] = "10";
itemToAdd["DateOf"] = DateTime.Today;
itemToAdd["Type"] = "1";
itemToAdd["Project"] = "1";
itemToAdd.Update();
}
}
}
}
}
catch (Exception e)
{
//Log errors
Console.WriteLine(e);
}
}
And I am making call like below:
Vote.DoneVote(table);
I havn't got any error, but itemToAdd
not adding in ListName
.
When I debug it I see, what table
has correct data.