Jul 9 2006

SQL Server Provider Statistics

Category: ASP.NET 2.0 - GeneralBil@l @ 12:14

SQL Server Provider in .NET Framework 2.0 provides a way to generate per-connection reports for measuring performance through a property in the SqlConnection object called StatisticsEnabled.

This is a sample code of how to do so:

SqlConnection conn = new SqlConnection(connectionString);
conn.Open();
conn.StatisticsEnabled = true;

// Perform data access operations

IDictionary stats = conn.RetrieveStatistics();

foreach (DictionaryEntry e in stats)
{
        Response.Write("Key : " + e.Key + " Value : " + e.Value);       
}

conn.ResetStatistics();



Hope this helps!

Regards

Tags:

Jul 7 2006

Microsoft Private Folder 1.0

Category: General | GeneralBil@l @ 11:29

   Microsoft released a new utility to password-protect your folder. This is the description from the Microsoft site:

Microsoft Private Folder 1.0 is a useful tool for you to protect your private data when your friends, colleagues, kids or other people share your PC or account. With this tool, you will get one password protected folder called 'My Private Folder' in your account to save your personal files. Download and have your private folder today!

The following hardware and software are required to run Microsoft Private Folder 1.0:

  • Microsoft Windows XP Home Edition, Professional Edition and Media Center Edition with SP2
  • Super VGA (800 x 600) or higher-resolution video adapter and monitor

Please note: Microsoft Private Folder 1.0 is provided specifically for genuine Windows customers, and requires genuine Windows validation in order to download. The software is free, and does not come with product support.

You can download the utility from: Microsoft Private Folder 1.0

Regards

Tags: ,

Jul 7 2006

Provider ToolKit Configuration Utility - Part 2

Category: ASP.NET 2.0 - GeneralBil@l @ 09:47

In a previous post, Provider ToolKit Configuration Utility, I published a small utility that helps you create all the needed files when you are building a new Service Provider Model.

In this post, I have upgraded that utility to allow you to create Providers not only related to Data Sources but rather to other APIs. Sometimes, we might need to create a provider that talks to a third-party API, which is in this case neither an Oracle, SQL Server, Microsoft Access, etc ...

In addition, the Namespace TextBox has been increaded in width to allow you to use long namespaces and at the same time be able to see it.

You can download the new version from the Files section above.

Hope this helps,

Regards

Tags:

Jul 6 2006

Parameter Types in C#

Category: General | GeneralBil@l @ 08:35

I read a nice article this morning, wanted to share with you, it is an old and every day article I guess. The article is titled: Parameter passing in C#. It explains in details the different parameter types we have in C#. So I will be just summarizing the ideas mentioned there!

In .NET we have mainly two types: reference types and value types. Reference types mainly hold a reference to an object, while a value type holds the data itself.

For example,

public void myMethod (StringBuilder mySB)
{
        mySB = null;
}

StringBuidler sb = new StringBuilder();
sb.Append("Hello World");
myMethod(sb);
Console.WriteLine(sb);


In this example, we created a reference called sb to a StringBuilder and appended some data, then called the myMethod and passing to it the value of sb and not sb itself and the value of sb in this case is a reference to the StringBuilder object. myMethod would now create a new instance of StringBuilder (as a new storage location) whose value is the value of the passed parameter and hence mySB points to the same StringBuilder object. myMethod then sets the mySB to null which means that the value of the instance created within the method is set to null, and hence when we print out the value of sb, it will be Hello World. I hope you were able to see the idea here which is that, we passed a reference to an object and not the object itself.

However, we can still see the value type in .NET in this example with a small varaiation.

public void myMethod (StringBuilder mySB)
{
        mySB.Append("World");
}

StringBuidler sb = new StringBuilder();
sb.Append("Hello ");
myMethod(sb);
Console.WriteLine(sb);
The same example as above, but within the body of the method, we have appended data to the same reference object. When we print out the value of sb it will be "Hello World". Remember, both instance created refere to the same StringBuilder object and hence when you update the value or data inside the object through one reference, the update will be seen by all objects refering to that StringBuilder object. 

We have 4 different types of parameters in C#:

  1. Value Parameters
    Value parameters hold the data itself. When passed to a method, a new storage location is being created in memory. An example illustrates this type:

    public void myMethod (int myInt)
    {
            myInt = 10;
    }
    
    int newInt = 50;
    myMethod(newInt);
    Console.WriteLine(newInt);
    Since the simple data types such as int, double, character are passed by value, the method myMethod will update the current value of newInt and return it back tobe 10.
  2. Reference Parameters
    By default, classes, delegates, interfaces, arrays, etc .. are passed as a reference. However, sometimes you need to pass not only the reference to an object, but rather the whole object. Check this example:
    public void myMethod (ref StringBuilder mySB)
    {
            mySB = null;
    }
    
    StringBuidler sb = new StringBuilder();
    sb.Append("Hello ");
    myMethod(ref sb);
    Console.WriteLine(sb);
    In this example, we have used the ref keyword which is required when we want to pass a variable by ref. Notice that when we pass a parameter to a method preceeded by ref keyword, we are not passing the value of sb (which is a reference to StringBuilder object) but rather the object itself "sb". myMethod won't create a new storage location but rather use the same storage location of sb, so when it set mySB to be null, means that it is setting the reference itself of sb to null, which means that sb now is null and doesn't refer to any StringBuilder object.
  3. Output Parameters
    Output parameters work much like the ref keyword. You pass a parameter with the out keyword, the calling method would fill out some data inside its body, and the updated data will be reflected outside the method. An example clarifies it more:
    public void myMethod (out int myInt)
    {
            myInt = 10;
    }
    
    int newInt;
    myMethod(out newInt);
    Console.WriteLine(sb);
    

  4. Array Parameters
    Array parameters allows you to pass a variable number of parameters to a method.
    public void myMethod (params int[] myInts)
    {
            foreach(int x in myInts)
            {
                    Console.WriteLine(x + " ");
            }
    }
    
    // Either you pass an array
    int[] newInts = {1,2,3};
    myMethod(newInts);
    
    // Or you send seperate parameters
    myMethod(3,5,7,8);
    

Hope you found my post helpful.

Regards

Tags: ,

Jun 27 2006

Store View State in a Persistent Medium, the Proper Way

Category: ASP.NET 2.0 - GeneralBil@l @ 01:13

I kindly invite you to check out my latest article on the ASPAlliance.com with the title:

Store View State in a Persistent Medium, the Proper Way

Hope you will enjoy it!

Regards

Tags:

Jun 26 2006

My visit to Athens-Greece

Category: General | GeneralBil@l @ 07:12

I have been in Athens-Greece for around 2 days in a business trip for  my company CCC. Things are going fine here, enjoying the beautiful Greece!!!

I will be soon back in Beirut!!

Regards

Tags: ,

Jun 18 2006

ToLowerCase or ToUpperCase in XSLT

Category: XSLT, XPath, XMLBil@l @ 20:35

This is a simple sample to show you how to transform the content of an element in an XML file from lower/upper case to upper/lower case

First of all define a variable of the element as:

    <xsl:variable name="Title">
      <xsl:call-template name="ToLowerCase">
        <xsl:with-param name="Field" select="Title"/>
      </xsl:call-template>
    </xsl:variable>

Then define the Template that will do the transformation:

  <xsl:template name="ToLowerCase">
    <xsl:param name="Field" select="''"/>
    <xsl:value-of select='translate($Field,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")'/>
  </xsl:template>

As you can see we are transforming all letters to lower case, the same can be done with a similar template to translate letters to upper case.

Hope this helps,

Regards

Tags:

Jun 12 2006

First day as a Trainer

Category:Bil@l @ 21:21

Today was my first day as a trainer at Formatech!

I am giving the Programming in XML with the .NET Framework.

I have 6 students in my class, and things went fine I guess for the first day!!!

This course will finish in two weeks, I enjoyed my first session, a new experience, new people to meet, ...

 

Regards

Tags:

Jun 7 2006

Pictures from my country, Lebanon!

Category: General | GeneralBil@l @ 21:08

I wanted to share with you those awesome pictures from my country, Lebanon. Hope you will enjoy them! I invite you all to spend some time here in Lebanon and visit most of its lovely sites we have here!!

Enjoy:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Regards

Tags: ,

Jun 6 2006

DnnCreative Magazine Issue 10

Category: DotNetNukeBil@l @ 18:18

You can now check the DnnCreative Magazine Issue 10!!

This is a completely free issue. For issue 10 we have created a completely separate DotNetNuke Skinning Resource, the DotNetNuke Skinning Toolkit.

This is a 98 page resource which demonstrates all of the skin classes within DotNetNuke so that you can easily view, search and learn how to style the various elements within a DotNetNuke skin.

This is a really useful reference tool for beginner and advanced DotNetNuke skin designers.

Following the research into the various DotNetNuke classes we have also outlined in further articles how you can reduce the CSS code required for a DotNetNuke skin, as well as tips for avoiding un-explained / un-wanted styling appearing in your DotNetNuke skins.

Tags: