SP – Uploading files to SharePoint document library

Posted by on Mar 9, 2010 in Sharepoint |

here we go, just some simple upload code that uploads documents into a document library.

It also checks if the same file exist in the destination library before upload.

Read More

Update Filename or List Item name programmatically in SharePoint/WSS

Posted by on Mar 9, 2010 in Sharepoint |

As simple as it sounds, it ain’t simple.

you would of thought the following would work:

does not compute..

There are 2 ways I’ve found of accomplishing this:

1. using the SPFile.MoveTo method:

2. using File.Item[“Name”] method..

However i have found method 1 more reliable. hope this helps!

Read More

WSS 3.0: Deleted Config LDF file – no backups, now what?

Posted by on Jun 26, 2009 in Deployment, Sharepoint |

Well guys, i just had the pleasure of deleting the LDF database file for my WSS 3.0 dev site.

Why? The server had literally 0.99MB of hard disk space and out of desperation, i deleted the 7GB log file by stopping the sql service and deleting the LDF file – i know, i wasn’t thinking straight…

Anyway, SQL went into a heap.. I couldn’t detach the database so i could re-attach it and re-create the logs..

The error was: It couldn’t find the log file so it couldn’t detach <- i mean how stupid is that…

Anyway, after fanning around, i uninstalled WSS3.0 and restarted the server.

Logged into SQL management studio, started a new Query and ran the following;

USE [master]
GO
CREATE DATABASE [SharePointTEST] ON
(FILENAME = N'D:\Path\To\Sharepoint\ConfigDB.mdf')
FOR ATTACH_REBUILD_LOG
GO

 Now, the other database has detached itself and the new database SharePointTest is up and working with a LDF file.

My main concern now was will WSS 3.0 install and connect to an existing database? is it smart enough?

I managed to install WSS as usuall (stand alone server), then i went to Central Administration and it said none had been configured so hit next and to my amazement it configured it and launched sharepoint and boom i was back to my old sharepoint site.

Fantastic huh!

Read More

SharePoint application logs massive!!

Posted by on Jun 25, 2009 in Sharepoint |

After doing some development/webpart work on our sharepoint server, the log file to grew to 3.5GB – we have 0.99MB of free space of a 20GB disk (this is a dev/test Virtual server).

Anyway after searching, i came across this blog: http://blogs.vertigo.com/personal/steventap/Blog/archive/2007/01/19/managing-sharepoint-2007-moss-application-log-size.aspx – thanks Steven!

Apparently you can manage how SharePoint logs it’s events:

The Problem:

SharePoint 2007 by default stores 48 hours worth of logs in a directory buried in your program files folder (C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\LOGS\ !). Very few events get logged to the application event log.

Expect each log file to be at least 200 megs (a log file being generated every 30 minutes by default), or 19 GB of space at the minimum being used by SharePoint logs.

Solutions:

Go to your central administration server web site, and open up the Diagnostic logging:

Central Administration -> Operations  -> Logging and Reporting -> Diagnostic logging

 

In the Diagnostic logging page, focus on the following categories:

  • Event throttling: how much you log
  • Trace Log: where you store the logs

Event Throttling:

  • For a Dev/staging server server, you should log all or “medium events”
  • For a Production server, only log errors
  • The search crawler will take up most of the log space

Trace Log:

  • By Default, logs are sent to: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\LOGS\
  • Store the logs on a separate drive so that at worse your drive gets full and your application stops logging, but still functions. It’s a pretty standard practice for SQL server installations for instance.
  • Reduce the number of log files. The default is two days worth of logging (96 files x 30 min intervals). See if this is too much for you; it might depend on how much you chose to log in the Event Throttling.

Read More

Sharepoint – Unknown Error has occurred

Posted by on May 28, 2009 in Sharepoint |

I too have dreaded this error – it means nothing to me and just pisses me off especially when developing webparts.

You can remove this by opening the web.config,

Search for <customErrors mode=On /> and change it to <customErrors mode=Off />

To see the call stack and trace information. Find

<SafeMode MaxControls=200CallStack=falseDirectFileDependencies=10TotalFileDependencies=50AllowPageLevelTrace=false>

and change the value of “CallStack” to true.

<SafeMode MaxControls=200CallStack=trueDirectFileDependencies=10TotalFileDependencies=50AllowPageLevelTrace=true>

Finally, don’t forget the set debug=”true” in the web.config or it won’t matter whether you put the assembly in GAC or not without it the breakpoints will turn all nice and red, but it won’t stop anywhere. If you want to enable generation of debug symbols for just in time compilation Find

<compilation batch=false debug=false>

and change it to

<compilation batch=false debug=true>.

Although none of these are appropriate for a production environment, but they all make development much easier.

-Ibrahim Sukari

Read More

Backing Up Sharepoint & ZIP (compress)

Posted by on May 16, 2009 in Sharepoint |

Hi All,

I want to publish the backup script i use to backup sharepoint every night. It is a very basic BATCH script (.bat) which uses STSADM sharepoint command line tool to backup sharepoint then uses winrar to zip and compress the file in date format then copy to the destination drive. 

# setting a the variable stsadm as the location of the command line tool
set stsadm="C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\stsadm.exe"
# set the variable %todaysdate% as todays date
set %todaysdate%=%date:~7,2%_%date:~4,2%_%date:~10,4%
# make a directory for today's sharepoint backup
mkdir E:\Backups\Sharepoint\File\%todaysdate%
# we are using the STSADM tool to make a full sharepoint backup
%stsadm% -o backup -directory E:\Backups\Sharepoint\File\%todaysdate% -backupmethod full
# this is zipping up the sharepoint backup as SharepointBackupXX_XX_XX.rar from contents of E:\backups\sharepoint\file\
"c:\program files\winrar\winrar.exe" a -u -r -m5 "E:\Backups\Sharepoint\Zip\SharepointBackup%date:~7,2%_%date:~4,2%_%date:~10,4%.rar" "E:\Backups\Sharepoint\File\%todaysdate%\*.*"
# this is copying the contents of "ZIP" to the destination backup drive which is mapped as S:\
 xcopy "E:\Backups\Sharepoint\Zip" "S:\Sharepoint\" /Y /E


Any comments or suggestions are welcome.

-Ibrahim

Read More
%d bloggers like this: