Using Microsoft. SharePoint;
Spweb site = Spcontrol. getcontextweb (context );
Splistitemcollection items = Site. Lists [ " Listname " ]. Items;
Splistitem item = Items. Add ();
Item [ " Field_1 " ] = Onevalue;
Item [ " Field_2 " ] = Twovalue;
Item. Update ();
Delete Sharepoint list data
========================================================== =====
Using Microsoft. SharePoint;
Spweb site = Spcontrol. getcontextweb (context );
Splistitemcollection items = Site. Lists [ " Listname " ]. Items;
Items [ 0 ]. Delete ();
Upload a file to SharePoint
========================================================== =====
Using System. IO;
Using Microsoft. SharePoint;
If (Htmlinputfile1.postedfile ! = Null )
{
Spweb site = New Spsite (destinationurl). openweb ();
Stream stream = Htmlinputfile1.postedfile. inputstream;
Byte [] Buffer = New Bytes [stream. Length];
Stream. Read (buffer, 0 ,( Int ) Stream. Length );
Stream. Close ();
Site. Files. Add (destinationurl, buffer );
}
Query records and update data
========================================================== ========
Using Microsoft. SharePoint;
Spweb = New Spsite ( " Http: // Nick " ). Openweb ( " Test " ); // Open website
Web. allowunsafeupdates = True ;
Splist list = Web. Lists [ " Listname " ];
Spquery = New Spquery ();
Query. Query = " <Where> " +
" <And> " +
" <EQ> <fieldref name = \ " Filed_1 \ " /> <Value type = \ " Text \ " > Test </value> </EQ> " +
" <EQ> <fieldref name = \ " Filed_2 \ " /> <Value type = \ " Text \ " > " + ( String ) Onevalue + " </Value> </EQ> " +
" </And> " +
" <EQ> <fieldref name = \ " Filed_3 \ " /> <Value type = \ " Text \ " > " + ( String ) Twovalue + " </Value> </EQ> " +
" </And> " +
" </Where> " ;
Query. rowlimit = 10 ;
// Query
Splistitemcollection items = List. getitems (query );
Try
{
If (Items. Count ! = 0 )
{
// Update Sharepoint list data
Foreach (Splistitem list In Listitems)
{
List [ " Filed_1 " ] = Textbox1.text. tostring ();
List [ " Filed_2 " ] = Textbox2.text. tostring ();
List [ " Filed_3 " ] = Textbox3.text. tostring ();
Listitem. Update ();
}
}
Else
{ // Add data records to SharePoint
Splistitem addlist = List. Items. Add ();
Addlist [ " Filed_1 " ] = Textbox1.text. tostring ();
Addlist [ " Filed_2 " ] = Textbox2.text. tostring ();
Addlist [ " Filed_3 " ] = Textbox3.text. tostring ();
Addlist. Update ();
}
}
Catch
{< br>
}< P>
from: http://www.cnblogs.com/jhobo/archive/2007/06/06/773650.html