SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to add few details for a item that is added to a list to SQL database table using a stored procedure, it works perfectly but when I upload multiple files it adds all of the items into the database, whereas My requirement is to just add 1 any of them Item details in the database, not sure if I can do it or not, here is the code.

    public override void ItemAdded(SPItemEventProperties properties)

   // System.Diagnostics.Debug.Assert(false);

            SqlConnection sqlConnection = new SqlConnection(ConnectionString());
            SqlCommand command = new SqlCommand("InsertItemDetails", sqlConnection);
            command.CommandType = CommandType.StoredProcedure;

            command.Parameters.Add("@SiteURL", SqlDbType.VarChar).Value = properties.WebUrl;

            command.Parameters.Add("@ItemName", SqlDbType.VarChar).Value = properties.ListItem.Title;

            command.Parameters.Add("@TimeItemAdded", SqlDbType.DateTime).Value = DateTime.Now;


I think I can add a filter for URL as if it already exists in database then delete that row and add a new Item, but not sure if it will be effective solution.

share|improve this question
up vote 0 down vote accepted

I created two more stored procedures,

  1. One for checking if any item exists in table
  2. Second to delete all records associated to item details of added item

so first I check if item details are in DB if they are then delete them and add a new item new details.

Hope it helps if someone else came across same problem :)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.