Thursday, January 1, 2009

How to Work on web part with out Sql Server Express

To work with web parts if you dont have sql server express or you want to point your webparts settings to some other database then configure your web.config file.

Step1# Define Connection String that points to your database.
Step2# Define ConnectionStringName property of Defualt provider to your Connection String defined in step#1
step#3 If web parts are not working or throwing exception of Schema then use aspnet_regsql.exe to create schema(Tables and stored Procedures) by Asp.net so that data used for webparts is retrived and saved again in your define database.

Enjoy ;)

web.config --- Code
<appSettings/> <connectionStrings> <add name="LocalSqlServer1" connectionString="Data Source=server;Initial Catalog=database_rahim;User ID=rahim;Password=test/> </connectionStrings> <system.web> <webParts> <personalization defaultProvider="SqlPeronalizationProvider"> <providers> <add name="SqlPeronalizationProvider" type="System.Web.UI.WebControls.WebParts.SqlPersonalizationProvider" connectionStringName="LocalSqlServer1" /> </providers> </personalization> </webParts>

4 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. if some one want to show the closed webparts on the page as a list simply do the following step (these are basic)

    1- Add CatelogZone control
    2- Add CatelogPage Control in the above zone
    3- then add mentioned below line on the page load or in button click event.

    this.WebPartManager1.DisplayMode = WebPartManager.CatalogDisplayMode;

    ReplyDelete
  3. Good work ! hira.

    This code basically get all of webparts in your page we can say catalog as a bucket of weparts

    ReplyDelete
  4. Hi Sir,
    Its a very helpful post. What i learned was to make webparts from 'Web User Controls' that is .ascx file. And I did put the compiled dll in GAC and also edited the sharepoint site`s web.config file so that sharepoint could recognize me webpart as a safe control. It its not opening my control saying that its not safe. I also reduced the risk level of my site from low to medium (as mentioned in msdn). Please guide me in it.
    Saad Ahmed Khan (CMS - PAF Kiet)

    ReplyDelete