Sunday, March 14, 2010

How to convert a comma seperated file (.csv) into a dataset (C#)

A small program to convert .csv file into a dataset which returns a dataset.

public DataSet CSVFileParser( string fileName)
{
     string pathName = System.IO.Path.GetDirectoryName(fileName);
     string file = System.IO.Path.GetFileName(fileName);
     OleDbConnection excelConnection = new OleDbConnection
     (@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+ pathName + ";Extended Properties=Text;");
     OleDbCommand excelCommand = newOleDbCommand(@"SELECT * FROM "+ file, excelConnection);
     OleDbDataAdapter excelAdapter = newOleDbDataAdapter(excelCommand);
     excelConnection.Open();
     DataSet ds = new DataSet();
     excelAdapter.Fill(ds);
     excelConnection.Close();
     return ds;
}

Hope this is helpful. Happy coding!

Friday, March 12, 2010

URL Escape Characters

What is the % Code in My URL?

In order to prevent the misinterpretation of special characters such as a space, bracket (< and >), or % in the URL (which stands for Uniform Resource Locator - it is the address you see in your browser's address bar indicating the location of the website you are visiting), browsers parse certain special characters using URL escape characters.

Table of URL Escape Characters
Character Escape Character Character Escape Character
Space %20 # %23
$ %24 % %25
& %26 @ %40
' %60 / %2F
: %3A ; %3B
< %3C = %3D
> %3E ? %3F
[ %5B \ %5C
] %5D ^ %5E
{ %7B | %7C
} %7D ~ %7E

 

Good Coding Practice

It is good coding practice to avoid the need for URL escape characters. As a rule of thumb, avoid using the special characters above when formulating a URI string (filename), and I recommend using the hyphen (-) instead of the underscore (_) (as all search engines recognize the hyphen as a space separator, but the same is not true for the underscore; and older browsers do not correctly interpret the underscore in CSS). If you must use the above characters make sure to escape them using the above escape characters so when the browser parses your code it will not misinterpret the link. It's important to note that these URL escape characters differ from HTML escape characters.

Which ajax control toolkit version?

You need the Toolkit version 1.0.20229.0, AjaxControlToolkit.zip the dll's are targeted to .NET 2.0 and you need also the ASP.NET AJAX Extensions 1.0 for .NET 2.0.

Monday, March 01, 2010

FireAtlas – Firebug for ASP.NET

FireAtlas is a Firebug extension dedicated to ASP.NET AJAX. It enables tracing of PageRequestManager events, Partial Updates and WebService calls.
It lists all ASP.NET Ajax components instantiated in a page.

fireatlas

FireAtlas will provide you with useful services when developing ASP.NET AJAX web sites:
* PageRequestManager events tracing
* WebService calls tracing and inspection
* Partial Update inspection within Firebug Net Panel
* ASP.NET Components listing

This add-on can be downloaded here.

Here are the extensions available for Firebug.

Facebook Toolkit for Microsoft Developers

Build your own FaceBook applications with ASP.NET, ASP.NET MVC, WinForms or Silverlight !

Read More

Download the SDK

  • Facebook.dll: This is the main assembly that will be used by all applications. This has all the logic to handle communication with the Facebook application. This assembly also has specific support of XAML applications (Silverlight and WPF) to enhance the Facebook platform to make databinding and data caching easier.
  • Facebook.Silverlight.dll: This is the Silverlight version of the main assembly that will be used by all Silverlight applications. This has all the logic to handle communication with the Facebook application. This assembly also has specific support of XAML applications to enhance the Facebook platform to make databinding and data caching easier.
  • Facebook.Web.dll: This assembly should be used by Canvas applications. The main functionality supported in this assembly is to encapsulate the handshake between the Facebook application and a canvas application (both FBML and IFrame)
  • Facebook.Web.Mvc.dll: Provide a support building canvas applications using ASP.NET MVC. Separated from Facebook.Web.dll to avoid all developers from needing to install the MVC bits.
  • Facebook.Winforms.dll: This assembly provides support for writing Facebook applications using Winform technology. This provides a Component that wraps the API to make it easier to use from Winforms. This also contains some user controls to help display Facebook data easily.