F5 Debug…

Building & Debugging the Technology!!!

Archive for the ‘.Net’ Category

Installing and Developing ASP.NET MVC 4 Application

Posted by Karthikeyan Anbarasan on January 5, 2012

Introduction:

In this article we are going to see how to install required tool for ASP.NET MVC 4 and develop a simple MVC 4 application using the Visual Studio 2010. Asp.Net MVC 4 framework is used for developing reliable application using the Model View Controller pattern. As of now MVC 4 is currently a developers preview and not released as a RTM. We can use this to develop mobile and windows application along with the Windows Azure environment. Let us see the step by step process on installing the MVC 4 framework and create a simple application.

Steps:

For installing the MVC 4 framework, we can download it using the below link

http://www.microsoft.com/web/gallery/install.aspx?appid=MVC4VS2010&prerelease=true

Once we clicked on the above link we can see the Web Platform Installer will be opened and the MVC 4 framework is available for installation as shown in the screen below.

2012-01-04 22h09_16

Now click on Install and we can see the prerequisites required to install the framework as shown in the screen below.

2012-01-04 22h17_44

We can see the installation progresses and once the installation is completed we will be navigated to the finish screen as shown in the screen below.

2012-01-04 22h20_10

Screen after the installation gets completed.

2012-01-04 23h03_53

Now open Visual Studio 2010 Environment and create a new project. We can see the ASP.NET MVC 4 application template available as shown in the screen below.

2012-01-04 23h07_06

Now we can see a window pop up to select the type of the application template. We will select the internet application as shown in the screen below.

2012-01-04 23h09_33

Now click on OK to proceed further and we can see the application opened in the Visual Studio IDE as shown in the screen below.

2012-01-04 23h10_47

Now to check the default template project look like just build and execute the application by pressing F5 and we can see the MVC 4 application opened as shown in the screen below.

2012-01-04 23h12_28

Now we are well set to make changes to our MVC 4 application as per the requirement.

For the new readers of this blog if you would like , you can follow me in one of the ways below to get update of posts on the latest technology
Twitter @ http://twitter.com/f5Debug
Facebook Page @ http://www.facebook.com/profile.php?id=100002468858656
Linked In @ http://www.linkedin.com/pub/karthikeyan-anbarasan/1b/78b/9a4
Google + @ https://plus.google.com/117525632086880345410/posts
RSS Feed @ http://feeds.feedburner.com/f5debug/Karthik

Posted in MVC | Tagged: , , , , , | 3 Comments »

Microsoft All-In-One Code Framework – Free Download

Posted by Karthikeyan Anbarasan on July 28, 2011

The Microsoft All-In-One Code Framework is a free, centralized code sample library driven by developers’ needs. The goal is to provide typical code samples for all Microsoft development technologies, and reduce developers’ efforts in solving typical programming tasks.

The list of code available are as follows

  1. C++
  2. ASP.NET
  3. Silverlight
  4. Windows Azure
  5. Windows General
  6. WPF
  7. Windows Forms
  8. Office
  9. Interop & Fusion
  10. VSX
  11. WF
  12. COM
  13. ADO.NET
  14. Windows

We have 2 options to download the sample, we can download it based on the technology required, or we have a single one click installer which will download all the samples to the local and install it in a single place.

To get the free sample go to the link http://1code.codeplex.com/

Happy Programming!!!

 

Posted in .Net | Tagged: , , , , , | Leave a Comment »

Article of the Day – ASP.NET Official Site

Posted by Karthikeyan Anbarasan on July 17, 2011

Today my article has been posted in ASP.NET Official Site as Article of the day

http://www.asp.net

Posted in ASP.NET | Leave a Comment »

Read and Write Excel data using C#

Posted by Karthikeyan Anbarasan on June 17, 2011

Introduction:

In this article we are going to see how to use an excel sheet as a source to load data in windows application or a web application and use the same to export back to the excel sheet using C# and VB.net. This requirement is straight forward used in day-to-day activity, but most of the time end up messing in some section of the code.

Overview:

Normally when requirement comes with accessing the data from the excel sheet, we first choose to start with the office interop assemblies (Office Automation Assemblies) and make a connection to the excel sheet and start processing but it has some disadvantages using it over the web(Check this link for more details Issues). So the alternate option was to use the OLEDB Provider to read the data and use it for the front end with an additional parameter of passing the connection string to the excel sheet.

Now we consider that we have things ready to export and import data to the excel sheet and the data is available in a dataset or a data table. We can use the below code snippet’s to get the data passed to and fro to the excel.

The Below code snippet will be used to export the data from local to EXCEL Sheet.

Code : Writing data to Excel sheet

string connectionString = "Provider=Microsoft.Jet.OleDb.4.0; Data Source=D:\MySamplefile.xls; Extended Properties=Excel 8.0;"
 
using(OleDbConnection Connection = new OleDbConnection(connectionString))
{
Connection.Open()
using(OleDbCommand command = new OleDbCommand())
{
command.Connection = Connection;
command.CommandText = "CREATE TABLE [EmpTable$](EmpFirstName Char(100), EmpLastName char(100), EmpDept char(250))";
command.ExecuteNonQuery();
}
//Add values to the table (EMPTable) in the Worksheet
using(OleDbCommand command = new OleDbCommand())
{
command.Connection = Connection;
command.CommandText = "INSERT INTO TABLE [EmpTable$](EmpFirstName ,EmpLastName ,EmpDept ) VALUES('Karthik','Anbu','karthik.Anbu@xyz.com')";
command.ExecuteNonQuery();
command.CommandText = "INSERT INTO TABLE [EmpTable$](EmpFirstName ,EmpLastName ,EmpDept ) VALUES('Arun','Kumar','Arun.Kumar@xyz.com')";
command.ExecuteNonQuery();
}
 
 

Code : Reading data from Excel sheet

DataTable dt;

string connectionString = "Provider=Microsoft.Jet.OleDb.4.0; Data Source=D:\MySamplefile.xls; Extended Properties=Excel 8.0;"
using(OleDbConnection Connection = new OleDbConnection(connectionString))
{
Connection.Open()
using(OleDbCommand command = new OleDbCommand())
{
command.Connection = Connection;
command.CommandText = "SELECT * FROM [EmpTable]";
using(OleDbDataAdapter adapter =new OleDbDataAdapter())
{
adapter.SelectCommand = command;
adapter.Fill(dt);
}
}
}
 
 

Conclusion:

So in this article we have seen on how to do small manipulation of reading and writing excel data using C# which we normally require in our day-to-day coding.

Posted in C# | Tagged: , , , , , , , , , , | 3 Comments »