C#: DataTable to CSV

 

Recently I wrote a small program to allow me to connect to a SQL database and export a selected table to a CSV file. So I needed a method that can take in a DataTable and the delimiter character to use. The returned result is a string which can be save straight to a text file.

Below is the method in my program, you may copy, modify and use it in your own program.

I use a StringBuilder class to build my lines of comma separated values and then return it as a String type. Currently the code only format string values with double quotes inserted around the value and the rest is a straight output.

(more…)

Windows Phone 7: Write Your First App

Windows Phone

Got a Windows Phone 7 and want to write some cools apps for it? Microsoft has release some tools to the public so that programmers like yourself can get started! You actually don’t need a Windows Phone because the kit comes with an emulator. Anyways let get start by downloading the developer’s kit from the App Hub and press on “Download the free tools”.

The installation package includes the following:

  • Visual Studio 2010 Express
  • Windows Phone Emulator
  • Silver Light
  • XNA Game Studio 4.0
  • Microsoft Express Blend for Windows Phone
  • .NET Framework 4

(more…)

C#: How to get your computer and user name.

If you want to get your computer and user name from Windows in C# try this by using the WindowsIdentity class from System.Security.Principal namespace:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Principal;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            System.Console.Out.WriteLine(WindowsIdentity.GetCurrent().Name);
        }
    }
}

How to Play Games on Ubuntu

Before I migrated to Ubuntu I was installing games on my Windows operating system using Steam. Before I had upgraded to Ubuntu 10.10 I was using 10.04 and I tried to install some games using Wine, but failed. Few months ago Steam was available on the Mac OS X, I was so happy that I was able to download or purchase games for my Mac.

Anyways I tell you how to install Steam on your Ubuntu operating system. First you will need to install Wine. Go to Applications->Ubuntu Software Centre. Enter Wine in the search box and then install Wine Microsoft Windows Compatibility Layer and PlayOnLinux.

Wine will allow you to install Windows application on Ubuntu, but not all applications will work so you probably have to go to their web site and check out which applications are working on it.

PlayOnLinux allows you to select a list of all compatible Windows application that will work in Wine. So after have installed PlayOnLinux, press on the Install button and select the Games category and find Steam and press Apply. There you go it’s easy as that! Well Enjoy!

My New Samsung Galaxy S Android Mobile Phone

image

My Optus mobile contract has finished, and it was time to upgrade to a new phone. I was tossing between the Apple iPhone 4 and the Samsung Galaxy S. But I decided to go with Samsung because it has a bigger screen, very sharp graphics, YouTube loading time is faster compare to my Apple iPhone 3G; no restrictions not like the iPhone where you need to jailbreak to run apps that is not available on the Apple Appstore.

I am still going to keep my Apple iPhone for development, and now it’s time to start learn and develop on the Android platform.

Shares