Mariusz, Gorzoch tech Blog

Archive for April 2010

CurrentNavSiteMapProviderNoEncode and ‘Publishing pages’ not hosted in “Pages” library

with one comment

Publishing features on SharePoint brings a lot of fun for developers, but sometimes it is so tricky that you can spend ages fighting with small thing because you wasn’t aware about some internal implementation. Today I have such a issue associated with implementation of ‘CurrentNavSiteMapProviderNoEncode’.

Publishing pages created by users should be stored in “Pages” library, but if you go thru the google you can find a lot of articles saying that this can be overcome by simply adding few content types do normal “Document library”. Partly this is true. If you go that way you would be able to create new publishing pages and store them in any “Document library” you want.

Unfortunately, this goes with the cost, witch in my case cost me around 5 hours. If you store your publishing pages inside library with name is different then pages then your site map provider ‘CurrentNavSiteMapProviderNoEncode’ will behave differently then in case when you would store those pages in “pages” library. Take a look at bellow pictures to see differences:

1. In case publishing page is stored inside “Pages” library then breadcrumb menu looks like this:

2. In case you store your publishing pages in library different then “Pages” then:

The difference is that in case (2) your will not get your page title!!! (SIC!)

happy coding… I’m done for today!

Written by Mariusz Gorzoch

23 April 2010 at 16:11

Posted in Bez kategorii

BizTalk and Microsoft Access

leave a comment »

If you ever need to create solution where you will try to retrieve some data from Microsoft Access (MsAccess) you will hit two issues:

1. How to access MsAccess database

2. How should I provide path to the MsAccess database.

I’ve chance to go thru that so here are the answers:

Ad1: The easiest way is to write a peace of .Net code and call it inside “Expression shape”. In my case I wrote a generic class where you need to pass special XmlDocument which describe information which you need to insert into MsAccess database. Schema of this document looks like this:

Here we have two important things: Name attribute of “Table” element. This attribute is pointing name of the table to which we are trying to write. Second important thing is the “Rows” element, which contain one Row per each inserted record. Each Row element should contain all fields you want to fill with data as child elements. If you create structure like that, then you can use code shown bellow to insert data into MsAccess database:

public abstract class MsAccessHelper
     private const string IMAccessDSN = "IMDatabase";

     public static void IMAccessCreateRecord(
             XmlDocument RecordToInsert)

         string ODBCConnectionString =

         using (OdbcConnection dbConnection = new OdbcConnection(ODBCConnectionString))
             catch (Exception ex)
                 string Message = string.Format("There is a problem with accessing DSN=’{0}’. Make sure that it exist as system DSN and user accessing has proper permission (Inner exception: ‘{1}’)",
                                                     IMAccessDSN, ex.Message);
                 throw new Exception(Message);

             foreach (XmlNode row in RecordToInsert.SelectNodes("././/*[local-name()=’Row’]"))
                 StringBuilder sbFields = new StringBuilder();
                 StringBuilder sbValues = new StringBuilder();
                 List<OdbcParameter> param = new List<OdbcParameter>();

                 int idx = 1;
                 foreach (XmlNode field in row.ChildNodes)
                     sbFields.AppendFormat("[{0}],", field.LocalName.Replace("."," "));

                     OdbcParameter par = new OdbcParameter();
                     par.ParameterName = "p" + idx.ToString();
                     par.OdbcType = OdbcType.VarChar;
                     par.Value = field.InnerText;

                 string Fields = sbFields.ToString();
                 Fields = Fields.Substring(0, Fields.Length – 1);
                 string Values = sbValues.ToString();
                 Values = Values.Substring(0, Values.Length – 1);

                 string InsertSql = string.Format("insert into [{0}] ({1}) values({2})",

                 using (OdbcCommand command = new OdbcCommand(InsertSql, dbConnection))

As you can see I’m using Odbc connection to access MsAccess database.

Ad2: Answer on the second question can be found in above code example. As I didn’t want to hard code path to the Access database I’ve decided to use windows ODBC administration panel and define my source over there. This is good approach as in case of moving your Access database you just need to update ODBC definition and you do not need to recompile and redeploy your solution.

Have fun

Written by Mariusz Gorzoch

13 April 2010 at 16:50

Posted in Bez kategorii