Friday, March 26, 2010

How to retrieve specific node in an XML file using C#.Net

Here I hv given one of the problem with solution, when I was trying to retrieve specific node of xml file.
Suppose that we have result1.xml file 
<?xml version="1.0" standalone="yes" ?>
<NewDataSet>

  <tblResult>

  <SubmittalId>1</SubmittalId>

  </tblResult>

  <tblResult>

  <Decision>Declined</Decision>

  </tblResult>

  </NewDataSet>

If u want retrieve each node (SubmittalId) & (Decision) separately, we need to use GetElementsByTagName method & XmlAttributeCollection class
private void Button1_click(object sender, EventArgs e)
        {
                        string fdecision = "";
            int subid = 0;
XmlNodeList list = null;
            XmlDocument doc = new XmlDocument();
            doc.Load("pathname"+e.Name);
            list = doc.GetElementsByTagName("Decision");
            for (int i = 0; i < list.Count; i++)
            {
                XmlAttributeCollection xmlattr = list[i].Attributes;
                fdecision = list[i].InnerText;
            }
            XmlNodeList listsubid = doc.GetElementsByTagName("SubmittalId");
            for (int i = 0; i < list.Count; i++)
            {
                XmlAttributeCollection xmlattr1 = listsubid[i].Attributes;
                subid = Convert.ToInt32(listsubid[i].InnerText);
            }
            Console.WriteLine(subid);
            Console.WriteLine(fdecision);
    }

Tuesday, March 16, 2010

Sql Server error - A short note for developer

Yesterday when i was working with VS.Net 2008 I got following error. This happens when I try to make connection string with SQL Server Database.

"Could not load file or assembly 'Microsoft.SqlServer.Management.Sdk.Sfc, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified"

This error is very strange and i could not resolve it easily. I was working in Windows 7 ultimate. I checked everything but finally got to know the solution. This error happens when u try to connect with sql server 2005. This happened bcoz SQL server did not installed fully. So try to download
1. Microsoft SQL Server System CLR Types
2. Microsoft SQL Server 2008 Management Objects
3. Microsoft SQL Server 2008 Native Client
at
http://www.microsoft.com/downloads/details.aspx?FamilyId=C6C3E9EF-BA29-4A43-8D69-A2BED18FE73C&displaylang=en#filelist

I hope this post is useful for every developer!!!

Wednesday, February 24, 2010

MVC - Part 2

In one of my previous post i have explained what is MVC? In the post i just want to share some more points about MVC. ASP.NET MVC takes advantage of many advanced features of the C# 3.0 and VB.NET 9.0 languages. The pre-requsti of an MVC application are

1.Microsoft .NET Framework 3.5 Service Pack 1—The Microsoft .NET framework includes the Microsoft ASP.NET framework.
2. Microsoft ASP.NET MVC 1.0—The actual ASP.NET MVC framework that runs on top of the ASP.NET framework.
3. Microsoft Visual Web Developer 2008 Service Pack 1 or Microsoft Visual Studio 2008 Service Pack 1—The development environment for creating ASP.NET applications.
4. Also includes the option of installing Microsoft SQL Server Express

Instead of downloading one by one u can just download microsoft platform installer at one place
http://www.microsoft.com/web/gallery/install.aspx?appsxml=&appid=MVC

I recomend to read Sams ASP.NET.MVC Framework Unleashed Dec.2009 for a beginner to learn abt MVC. This book has explained briefly abt MVC. You can get the free download form here

http://www.filestube.com/s/sams+asp+net+mvc+framework+unleashed+jul+2009+rar

Saturday, January 23, 2010

A cooking recipe

I would like to share few personal things in this post. Everyone needs relaxation in this fast moving world. And everyone might have their own hobbies during their rest period. A hobby is an activity or interest that is undertaken for pleasure or relaxation, often in one's spare time. My favorite hobbies are cooking, playing chess, cleaning, listening to light melodies, watching TV, reading books etc. I am thinking to write some of these in forecoming posts. Let’s start with cooking.
Cooking is an art. We all have different tastes. There are vast varieties from sweets to spicy. As a tamilan, I too like spicy foods very much. And I like to serve my family with different varieties. So I am explaining one of those. A recipe for Brinjal Rice.
Requirement:
Brinjal/Eggplant = 1/2 kg
small onions = 200g
curry leaves = small qtty
Soombu=1 tbl spoon
pattai,krambu-2
Garlic-ginger paste 1 tbl spoon
chilly powder 1/2 tbl spoon
coriander leaves=small qtty
cooked ponni rice= 1/2 kg
cooking oil = small qtty
Preparation
Cut the brinjal/eggplant into small pieces. Put some oil in a kadai.After it gets heated, put sombu,pattai,krambu,curryleaves,onion. Later put some garlic-ginger paste into it. Then add finely chopped brinjal/eggplant into it. It should mixed well with masala. Add chilly powder and coriander leaves into it. The brinjal should get deeply fried. If u want, u can add some more oil. So now the gravy is ready u can add cooked rice with this and add some salt for taste. Its now ready and u can serve this with raita. It’s very tasty, even children will like more. It’s a great treat for spicy lovers. Try it & write comments. I will try to give more different recepies later.

Monday, January 18, 2010

A short note on MVC!

Everybody might have heard about Microsoft’s ASP.Net MVC framework. Here I want to share a little knowledge about MVC framework. MVC stands for Model-View-Controller and is one of the most popular design patterns for decoupling data access and business logic from data presentation and user interface. MVC composes of three different roles, Model—An MVC model contains all of an application’s logic that is not contained in a view or controller. The model includes all of an application’s validation logic, business logic, and data access logic. View—An MVC view contains HTML markup and view logic (the user interface). Controller—An MVC controller contains control-flow logic. An MVC controller interacts with MVC models and views to control the flow of application execution. The ASP.NET MVC framework enables you to build web applications that are easier to maintain and extend over time. The Model View Controller pattern encourages a clear separation of concerns. The framework also encourages good software design patterns.

For a developer who wants total control over every HTML tag and pixel that appears in a web page, the ASP.NET MVC framework is the ideal one. ASP.NET MVC also enables you to expose intuitive URLs to the world. Exposing intuitive URLs is important for getting your website indexed by search engines. This is important for Search Engine Optimization. The MVC Framework doesn't support classic postbacks and viewstate and doesn't consider any URL as the endpoint to a physical server file to parse and compile to a class. One of the other main advantages of using ASP.NET MVC framework was that it supports test-driven development. So no need to worry about unit testing anymore.

Saturday, January 9, 2010

Collective Intelligence

I would like to share few things about harnessing collective Intelligence in web which I read recently in an article. Collective Intelligence usually refers to combining the behavior, preferences, or ideas of a group of people to create novel insights. Whether you’re a bulding startup, a recognized market leader, or looking to take an emerging application or web site to the next level, harnessing information from users improves the perceived value of the application to both current and prospective users. This improved value will not only encourage current users to interact more, but will also attract new users to the application. The value of the application further improves as new users interact with it and contribute more content. This forms a self reinforcing feedback loop, commonly known as a network effect, which enables wider adoption of the service. Amazon’s recommendation systems, Wikipedia, Google’s page ranking etc are top most examples in today’s web application. Collecting answers from a large group of people lets you draw statistical conclusions about the group that no individual member would have known by themselves. Hence harnessing collective intelligence play a vital role in a web2.0 application.