Archive

Archive for November, 2005

Retrieving random images from picture library in sharepoint

November 21st, 2005 No comments

If you are planning to create a web part that can retrieve and display a thumbnail of a random image from the picture library, then you have two options:


1) The images are stored as binary fields in the DOCS table inside the _SITE database. The field name is CONTENT. Simply connect to the database to retrieve the image. This is not the way I usually get stuff done in SPS.


2) I would suggest you access the images via the Sharepoint namespaces. Picture libraries store their image files in the same manner as document libraries store documents, so get a reference to the picture library as an SPList class and retrieve the image from the SPListItem.File property.


 


protected override void RenderWebPart(HtmlTextWriter output)
{
   string url;
   string caption;


   string HTMLtext;
    try
      {
         SPWeb mysite=SPControl.GetContextWeb(Context);
         SPListCollection lists=mysite.Lists;
         foreach (SPList list in lists)
            {
            if (list.Title.Equals(PicLib.ToString()))
                  {
                  SPListItemCollection items=list.Items;
                  int rndCount=items.Count;
                  if (rndCount > 0)
                     {
                         int intRandom=rIndex.Next(1,rndCount);
                         url= items[intRandom].File.Url;
                         caption=items[intRandom].File.Title;
                         HTMLtext= “some html text”;

                         output.Write(HTMLtext);
                     }
                  else
                    {
                  output.Write(“There is no picture in the selected picture library.”);
                    }
              }
          }
      }
catch(Exception e)
      {
      output.Write(SPEncode.HtmlEncode(e.Message.ToString()));
      }
}

Categories: Uncategorized Tags:

SQL Server comparison tools

November 17th, 2005 No comments

“There are so many SQL server database and structure comparison tools; may I know which one is better?”. Well this is one of the most frequent questions, asked in SQL Server communities,therefore I decided to clarify this based on my experience and the products I’ve used so far.


I mainly use Red Gate SQL Bundle developer edition for all DB related tasks and mostly for keeping my DBs in sync as I move up from dev to test to pre-prod and finally production, that’s why I prefer Red Gate myself. Doesn’t mean it’s “better”, I think that’s a personal subjective thing, but there are two more possibilities that I’m aware of:


1) Apex


2) DB Ghost


When I first used Apex SQL Edit, I was under the impression that their products are NOT as polished as they should be; it hangs a lot when it comes to huge databases and it hugs the resources a lot, so for the sake of this article, I took their products out of my benchmarking task. I’ve mucked around with DB Ghost a lot recently and I have found it to be extremely reliable and it provides additional capability beyond comparison e.g. a rock-solid process to upgrade your databases (same as Red Gate),but still believe that from a developer’s perspective Red-Gate dose a better job than all its competitors. Below is only a feature comparison on Red-Gate and DB Ghost’s most popular product.


SQL Bundle Developer Edition  (Red-Gate):



SQL Compare and Synchronization:Yes
SQL Data Compare:Yes
DTS Compare: Yes (That’s really handy if you are using DTS as an ETL tool)
Build Database from Script:Yes
Scripter:Yes
Extra:SQL Toolkit (APIs and command line tools to programmatically compare database objects are all exposed to the clients)
Pricehttp://www.red-gate.com/dynamic/shoppingcart/QuoteProductOption.aspx?Product=SQLBundleDeveloper


DB Ghost Professional Edition™



SQL Compare and Synchronization: Yes
SQL Data Compare:Yes
DTS Compare:No
Build Database from Script:Yes
Scripter:Yes
Extra:Nothing
Price:http://www.innovartis.co.uk/database_solution_Purchase.aspx 

Categories: Uncategorized Tags: