where to store a unique ID?

Hello,

 

I want to store a unique ID to use in a webpart. In a aspx page I would do it with a database field and a stored procedure, but with webparts i don't know.

I want to give all my documents a unique ID, but not use the ID from sharepoint itself.



Answer this question

where to store a unique ID?

  • Orchid2006

    I'm using Sharepoint 2003, Visual Studio 2003.

    In this, Microsoft.SharePoint doesnt have the SPItemEventReceiver object....is this only for SharePoint 2007


  • Rhubarb

    I am sorry, but I don't understand how you want to use that ID.

    Please elaborate.



  • ahmedilyas

    Yesterday evening late, I found the Interface IListEventSink:

    using System;
    using System.IO;
    using Microsoft.SharePoint;
    using Microsoft.Diagnositics; //for EventLog
    
    public class EventSink : IListEventSink
    {
    
    public void OnEvent(Microsoft.SharePoint.SPListEvent listEvent)
    {
     if (listEvent.Type == SPListEventtype.Insert)
     {
      //do my actions
     }
    }
    
    }
    

  • robhare

    as soon as a document is being put in a library, a unique ID is given to that document.

    That unique ID will show on the library as e.g. a label.

    So as soon as the event triggers to place the document on the library, I want to fetch a new unique number. My plan was to store that number in the database, and get and raise it with a stored procedure each time there is a new document.

    I just don't know if it is possible in a webpart to use a database and a stiored procedure like i normally would in asp.net pages.


  • Oliver 123

    SPItemEventReciever is only for 2007, but there were event handlers in 2003 as well! (I just don't remember the name space).



  • ghw123

    Thank you.

    So it is possible then to connect to the database and put the unique ID there in my webpart

    Thx.


  • Rick Simmons

    true.

    Let me know if you hit problems.



  • DavidThi808

    Thank you.

    So the idea is to create a class that overrides the ItemAdded event, and then later on connect the document library's ItemAdded event to that...

    and by making a new class I can then make a connection to the database and store my unique number in there...

    If I'm wrong please let me know.


  • MadGerbil

    What you are looking for is not a web part. It is an event handler that attaches to the document library and overrides the ItemAdded event (read about ItemAdded event in the MSDN).

    This event will allow you to manipulate properties of the document once it's been uploaded.



  • SonicWave

    A web part is a piece of code, the same as an aspx page.

    It does have storage, but it is not a database management system, and does not offer protection from concurrency or locks etc.

    Why not do the method that you allready know how to do (use a database field and a stored proc) to create these IDs



  • where to store a unique ID?