Wednesday, July 22, 2009

DataView Webpart, SharePoint Designer & Sql express 2005

This is a step by step guide that i eventually used after hours of googling and binging coupled with anger at my screen for showing me endless generic errors, just maybe someone finds it useful

Task
Getting a dataview webpart to display data from sql 2005 express on a sharepoint page
tools
-running sharepoint site (WSS 3.0)
-sharepoint designer (SPD) 2007
-sql express 2005 (with sample databases & management studio express )
note that all the above are free downloads from microsoft :)
Get the webpart in place
Fire up your sharepoint designer and open the page on which you want to place your webpart. its good practice to use a fresh webpart page from which the webpart can be exported and later imported to any desired part of the site.
After opening the page click on the link (click to insert a webpart) in the desired zone on your page.
In SPD menu click insert - sharepoint controls - dataview
use the link in the empty webpart to show the Data Source Library if not yet open.


Prepare sql account
Make sure your sql express is up snd running,
in the object explorer under security, right click on logins to create an sql server account that we shall use in the connection. Note here i use an sql server account. d-click on the user and grant sysadmin permissions under server roles



next we are to chnage the default authentication mode of sql from windows to sql server and windows.
this is done by right clicking on the instance ([computername]\sqlexpress) under object explorer and then properties. In server properties under security change the server authentication to sql server and windows authentication mode, click okay. now we should be able to login using the account we just created using the SPD connection strings.

configure data source connection strings
back to SPD data source library, click connect to database under database connections. in the datasoure properties dialaog box, under general tab give your connection a name, here i leave it as default custom query as its the database am going to use. back to the source tab - configure database connection;
server name - [comutername]\sqlexpress
provider name - ms .net provider for oledb
authentication - use the details of the sql account you created.
and next, ignore the warning as this aint a producton scenario. and finally you are presented with a dropdown box to chose the databse to use, i will go for Adventure works and the contacts table. WAIT! DONT select any table .



NB: if u select a table and finish the wizard, then SPD will make a select statement of the form SELECT * FROM [Contact] and finally when you try to show the data you end up with the error below
"the server returned a non-specific error when trying to get data from the data source. check the format and the content of your query and try again."

sql server uses schemas to identify database tables and if u check the tables in studio you realise the contact table is under the person schema
and so the statements are expected to follow this structure
[ select * from person.contact]

so instead of selecting a table, we specify custom statements and edit the alreday existing commands to follow the schema structure.


click okay and u are well to go. in the connection if u click on show data it should bring up the fields which u can add to the dataview either as single item or multiple item.
here i added as multiple item view



and finally on my sharepoint page



there are many modifications that can be made to this wepbart like having links and the ability to modify which i will attempt in my next post.

Tuesday, July 14, 2009

SharePoint Server 2010

Incredibly powerful integration between sharepoint and office 2010 is the next version of sharepoint offers among other features. the integration of sharepoint workspace (formerly office groove) with synch abilities means a lot can be done even offline.
check out the overview here from business and developer perspective
The new tools coming with Visual studio 2010 offer more pwerful development experience in webpart visual designer and the Business connectivity service (BDC)modules. Also additions from .NET 4.0 components are included .Thumbs up to u guys.

Thursday, June 11, 2009

SP Document Library Type Icons

Hey all,
if u pay attention to detail you will realize that by default when you create document libraries you have the option of choosing which document templates to use for the library e.g word, excel, powerpoint or even sharepoint designer pages.
when anyone of these docs is created or uploaded to the library there is a type column under which we have icons corresponding to the respective document types.

But if u try to upload some other document types then by default sharepoint will use a white paper icon to represent that type. fortunately there is a way out;
i uploaded my pdf file along with an mp3 file in the same library and as you would expect the corresponding document type icon for both these files is a white paper icon.
First of all get the images you want to use as document type icons in the right size.
secondly get down the 12 hive to the TEMPLATE folder (C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE)
paste the image in the IMAGES folder and back to the XML folder, there open the file DOCICON.XML for editing,
all you have to do is add a mapping by extension for the image we want to use

Mapping Key="pdf" Value="myImage.gif" (make sure u add opening & closing tags as i left them out here intentionally)

note here that "pdf" is the extension so it could be any other file extension
save the file close and restart iis.
you should have nice icons in your document library like this;

Saturday, March 21, 2009

SharePoint Wiki Coding

Another pitfall!
Recently i was faced with a task of retrieving data from a WSS 3.0 wiki page to be used in some WebPart and discovered quite a few interesting things; Unlike other lists/folders a wiki has some special considerations in order to access its content.
An obvious approach was using the SPWeb object to retrieve the list item as;

SPListItem item = web.Folders[""].Files[]

Here the actual contents of the item is the aspx template used by the wiki page.
A wiki like other files has properties and you will need the [Wiki Field] property to access actual page contents to a string variable.

string wikiContent = item.Properties["Wiki Field"].ToString();

and you got it.

Saturday, March 14, 2009

Div CSS styles

hello designers,
recently had a task which could not suffice with old traditional tables(obsolete)
and had to ditch them for divisions. to make the outlook similar to how a table appeared before requires much use of css styles; a couple of them that were of use;

float:left /* to make two divs appear adjacent to each other(no break) */

position:relative/absolute /* can be used to set div position, handy for div shadows */

filter:alpha(opacity=60); /* transparent div in IE */

-moz-opacity: 0.6; /* transparent div for Netscape earlier versions */

opacity: 0.6; /* transparent div for mozilla and other gecko browsers */

to be sure use all in your css;

be careful with nested divs as styles can be inherited if not set inline for inner divs.

complete reference at www.w3schools.com.

Adding custom properties to webparts

Another handy tip for beginners; ever seen those properties that show up in the toolpane when u want to edit webpart? there is much more that can be added to suit your customization needs.
the general format of c# properties consists of a get and set method for the required value

if u add the following piece of code to the existing you shd get what u want;

[Personalizable(PersonalizationScope.Shared)] //enable personal views

[WebBrowsable(true)]

[System.ComponentModel.Category("My Properties")] /*create category for new property, will default to miscellaneous if undefined */

[WebDisplayName("Another Property")]



private string _anotherProperty;

public string AnotherProperty

{

get { return _anotherProperty; }

set { _anotherProperty = value; }

}

watch out for differences between sharepoint and asp.net webparts

Good luck!

Thursday, February 19, 2009

Importing MOSS sites to WSS

Ok this gave me a headache for sometime as i initially thought it was a matter of entering a few stsadm.exe commands and ur done.
the main issue is the difference in features available in MOSS sites as compared to WSS sites.
if a site in moss is using certain features which are not available in wss then the import will generate fatal errors of missing features notably transmgmt.lib, data connection library (dcl) en others. so what way to go
after a couple of thoughts it narrowed down to opening the file in notepad and editing out some of the features which i had not deactivated earlier on before exporting the site from the moss platform. after all rumble jumble as some errors will keep reappearing then ur good to go with
stsadm -o import -filename [filepath] -url[http://server/site]

the import is gonna require an empty site created according to the language setting of the site you are importing. otherwise you will get errors related to differing site template Id #1 and #0
this is just an account of my daily work so it seems unclear let me know
cheers

Wednesday, February 18, 2009

welcome

Hello, there
am quite new to this blogging habit but i guess its a dangerous bug that has caught up with me. i just wanna talk about a few things that have been useful to me in my new career and hopefully others might learn and avoid similar mistakes.
A Smart person learns from his mistakes
A wise person learns from others mistakes
cheers:)