Posts

Showing posts from 2013

Simple way to connect to SQL Server when you can't find server name

Image
sometime you will get a window like above when you try to connect to the SQL Server 08 (didn't check it on server 05. I think this will work on that on as well.) and you have no idea what is the name of the server. Then you can press a ". "(dot without double quotes) and press connect then you will be able to connect to the server. Simple right. Hope This will help you.  

WCF (Windows Communication Foundation) for beginners

Image
Hi guys after long time huh? so today i come up with a new topic but something very important to all of us. something you should really need if you are a great software engineer or a great programmer. so let's talk about WCF (windows communication foundation) by looking at a simple demo. because you can read lot of things regarding this topic in internet but the demos are kind of low to find. That's why I want to make this one a practical example. hope you understand. 1. so to create a WCF service or services you must create a new WCF project. (important run your visual studio as a administrator otherwise it'll not work)    Go to visual studio and from Installed template select WCF  and then select WCF Service library Project. 2. now give a proper name to the project. in here i'm going to give it a CalculationServices because this service is going to do simple calculation such as addition and multiplication. 3. Okay when you create a proje...

Solution for failed to create Configuration Database for MOSS 2007 on Windows Server 2003

Image
some time when after you install and try to run the configuration wizard you will get an error message like this. then you know idea to what to do. you go and check your SQL Server and Application pool, Services in the server and so many other things. but you can overcome this problem easily.  Solution check you have installed Microsoft office 2010 in your server. if so then uninstalled and re run the wizard. then it'll work smoothly. 

Walkthrough Func type in C#

Image
from my last post I talked about the Func type and Action type. so today also i'm going to go through that topic and show you a sample code of func type usage. Code is pretty simple and no need to explain in detail. go through it then you will understand that easily and also you'll get an idea about the Func type. of easy of demonstration i put all the method to program.cs class in console application project. Enums and Dictionary variables /// <summary> /// The dictionary to hold method names /// </summary> private static Dictionary<CalculationType, Func<int, int, int>> methodDictionary; /// <summary> /// CalculationType /// </summary> internal enum CalculationType { Add, Multiply, Subtract, Divide } Common Calculation methods /// <summary> /// Adds Two values and return the answer. /// </summar...

C# Func and Action Type Example

Image
From this article I'm going to show simple example of Func and Action Type in C#. before go to the coding let's see what's Func and what is Action. so in the previous article we talked about the delegates. so these func and Action types are also derived from delegate type. 1. Func  Func handle method with parameters therefore we say Func is Parameterized type. in Func we specified number and kind of parameters and what should be the return type. And Func type provides a way to store anonymous methods in generalized and simple way.  you can find more information about Func here . 2. Action  Action object return no value. so this is similar to void method in C# and we can use Action type to handle Void methods. Action method can found in System namespace. You can find more information about Action here . so let's go to a sample code and try to get idea about these concepts. class Program { /// <summary...

C# Delegates for Beginners

Image
Delegate is a type that can reference to a method. once delegate is assigned to a method it can behave exactly like that method. so now I'm going to show you a simple example to demonstrate how delegate is work.  so let's go to the code and check that one. I'll explain things while i show you the code. okay. To demonstrate this i created a console application named demo. now we need a simple class to add our calculation methods. so go to your project and create a class name Calculation and add following method to your class  1. C alculation Class /// <summary> /// Calculation Class /// </summary> public class Calculation { #region Public Methods /// <summary> /// Adds two values /// </summary> /// <param name="value1">The value1.</param> /// <param name="value2">The value2.</param> /// <returns></returns> ...

Command Design Pattern

Image
Today I'm going to show you another important design pattern which we can use for recurring  problems. Main intent of this design pattern are mention below  Encapsulate a request as an object, thereby letting you parameterize clients with different request, queue or log request, and support undoable operations. Promote "Invocation of a method on an object" to full object status . Promote  An object-oriented callback  You already know i'm kind of lazy person when comes to documentation as well as blogging lengthy articles he heee. so if you guys like to know more information about command pattern, please refer here . Okay let's try to implement this using a simple example. so today i'm going to create a simple calculator ( Windows form project) and it can do few operations such as add, subtract and multiplication. so let's see the code segment and then you will understand how this pattern works. 1. Ac...

Factory Design Pattern

Image
Today I'm going to show you a very simple code segment to understand the one of the most used design pattern in the IT word. As I mention on the Title it's Factory pattern and the main intent of this pattern is to create objects without exposing to the client and also refers to newly created object through a common interface. in this article I'm not going to explain you the theoretical parts. so I'm going to show you sample code now. here I use the famous Pizza story to come up with a solution. and you can get more details about this pattern here . 1. Create a IFactory Interface  /// <summary> /// IFactory Interface /// </summary> public interface IFactory { /// <summary> /// Pizza Create Method /// </summary> /// <returns></returns> string CreatePizza(); } 2. Create Domino's Class and Implement it using    IFactory Interface  /// ...

Deep dive into OpenXML Part 2

Image
So In the Deep dive in to OpenXML part 1 I showed you the common methods which we can use to generate an excel file. but most of you are not aware to use those methods so today i'm going to show you the way to use those method and generate an excel file.  for this exercise use a Console application project. Excel File Generator Class /// <summary> /// File Generator Class /// </summary> class FileGenerator { #region Variable Declaration /// <summary> /// Column Span for Grouping /// </summary> private const string ColSpanLine = "1:4"; private const string SheetName = "Sample"; #endregion #region Public Methods /// <summary> /// Generates the report. /// </summary> /// <param name="reportList">The report list.</param> /// <param name="fileLocation">Th...

Simple Model View Presenter Demo in C#

Image
Model View Presenter is a software approach pattern conceived as derivative of Model View Controller. What is Model? Model is a domain level or business level object. A model accommodates application data and provides behaviours to systematically access it. It should be independent, it should not have any association with user interface issues. So we can reuse the same model for different type of UI level applications. What is View? A View is a windowpane for showing the model data or elements to the application users. Model does not have direct link to the views. View know about their Models, but not the other way around. What is Presenter? Presenter will address the user input and use this to manipulate the model data. View will pass the user input actions to the Presenter for interpretation. Presenter will act on the received data from View and communicate with Model and produce results to the View. Okay now we are going to do a simple Demo to get hand on experience a...

Recursive Method to find control in complex page

Image
Today I'm going to show you a simple method to find a control (Textbox, Dropdown, Label) in a complex Page where default findControl method is not useful. Using this method you can identify the control easily and it's recursive method so the LOC is few. enjoy it. /// <summary> /// Find a control when Root control is known /// </summary> /// <param name="rootControl">Instance of the Root control</param> /// <param name="controlToFind">Name of the control to find</param> /// <returns></returns> private Control FindControl(Control rootControl, string controlToFind) { return rootControl.ID == controlToFind ? rootControl : (from Control control in rootControl.Controls select this.FindControl(control, controlToFind)).FirstOrDefault(t => t != null); } hmmm That's all.simple huh. happy coding and have a nice day.

Deep dive into OpenXML Part 1

Image
Okay guys today I'm going to say about the Excel manipulation using the OpenXML. you can do various things using OpenXML and here I'm going to explain most important things you should know about OpenXML when comes to the Excel programming. okay then let's start. First of all go to visual studio and create a console Application. To work with OpenXML you need to add several Dlls to your project. so after you create the project then go to project reference and add following dlls.        1. DocumentFormat.OpenXml. you can download this dll from here .        2. WindowsBase okay now we are half there. now our project is ready to welcome the OpenXML. so let start coding and make some application.       so now we need to add a class called ExcelUtilities to put our common method which we are going to  use every time. so let's go and create that class and add those common methods and don't forget to add these namespaces t...