Monthly Archives: March 2010

A DVD collection


First Page

The first page where I've not inserted any data

Well in .NET 3.5, LINQ has made data query, inserting, updating and deleting so easy that, you almost don’t have to write a code.

Second Page

I'm going to insert data

Third Page

After insertion the new data has been shown

All I have done through wizard, except making some change in LinqDataSourceControl, and the change is very small.

The steps are also not very difficult. First of all, I go for a file system new web site in VS 2008. In the App_Data folder, create a SQL Database DVD_Collection.mdf which has one table DVD having three columns : DVDID (int, primary key, auto increment on), Name(verchar 20), Artist(verchar 20).
After creating the database and the table all I had to do was create an App_Code folder. In App_Code folder added new item LINQ(.dbml) and dragging the table into designer section.
Next step is, getting a LinqDataSource in the page where I want to retrieve data and manipulate them and connect it to the table class that LINQ had created.
Finally, in a ListView data control got the LinqdatSource connected and make Inserting, Updating and Deleting property true.
The whole procedure does not require you to write a single line of code.
But the DVD Collection is data base driven. One can add any number of items there without bothering about any error!
The funny part of the whole thing is, in ASP.NET(.NET 3.5), you did not need to write a single line of code to make a data base driven site,
But, in PHP, if you want to do the same thing in an Object Oriented way, you need to write a long long code.
In the next post I’ll do the same thing in PHP, and you find what is more preferable to you.
Best of Luck.


A few good ‘ASP.NET Tutorials’


Well, I really came across very many good tutorials that has made my ASP.NET learning interesting and at the same time useful.
To start with I’d like to remember C#Friends. It was an extremely helpful forum where an expert, nicknamed ‘vulpes’ taught me the basic of C# Programming Language. He is terrific.
You can still find him, but not in C#friends as it was changed to This Forum

Next I’ll mention a few good sites where you can get very helpful video tutorials. The first and foremost of course the home site.
Data Access Tutorials
To start with…
All about
Web Forms

The great How Do I Series
The great ASP.NET tutorials by Scott Mitchel
For the people who want to dig deep
ASP.NET Officially yours!
All the C# learning trains should once stop here!
Get some ASP.NET projects
A must stop for C#
All in one, very helpful

MSDN has the Last Word

Well hopefully it’ll come to your help. If anyone has any other links to share please write in the comment section. Best of luck.

A few good ‘PHP Tutorials’


Well, I’d like to share few very good tutorials both in PHP and ASP.NET so that new comers to the dynamic web languages may get benefited.
When I started PHP, not very far away from today:), in fact I’d like to remain student all along to the end of my journey, I found a video tutorial called ‘killerphp’, very nice.

Other useful php tutorial links are

Stefan Mischook’s tutorials

Very useful php beginner
Plenty of good free source codes
I like this one
A must watch
Last but not the least, a good forum and tutorial
Plenty of free helpful codes
Best of luck. In the next post I’d share some good C# and ASP.NET tutorials.

Database and SQL query in PHP and ASP.NET


After many many days, today early in the morning, I found some time to make a connection to a MySql Database and do some PHP.
It was a good experience all together. After all, now, for the time being, I’m busy doing some database operation in ASP.NET.
In the midst of ASP.NET, some PHP and MySql brings a fresh breeze.
Now for the people who want to do some database operation in PHP, I’d like to share my experience.
Besides, I’ll give an example of ASP.NET database operation so that readers can compare the pros and cons of two great dynamic web language.

First PHP. The code is very simple:

A MySql Database Connection Made

Database name is ‘produce’, table is ‘products’ which has three columns


$connection = mysql_connect("localhost", "root", "") or die("Could not connect");
$db = mysql_select_db("produce", $connection) or die("Could not select database");
$query = "SELECT * FROM products";
$result = mysql_query($query);

echo "

echo “

echo “


while ($row = mysql_fetch_array($result))

echo “

echo “


echo “

Product ID Product Name Product Number
“, $row[‘productID’], “ “, $row[‘productName’], “ “, $row[‘ProductNumber’], “




It looks like this:

I have made a database 'produce' through PHPMyAdmin, then made a table named 'products', after that I made three columns with 'productID' having primary key.

In ASP.NET, if I want to do the same thing, I don’t have write a single code! The fun of that web language lies there. There are so many options to connect to the Database, be it Oracle, MSSQL or anything else, and there is also so many options to operate that database through various data source controls, that in PHP the lazy programmers will definitely feel the heat! 🙂

Using User Control


It took nearly entire morning to figure out where was the actual fault! I tried first in my Laptop, and the user control did not work.

Next I tried in my GrandPa. The old AMD Athlon desktop that has been assisting me to do everything that I could have imagined since seven years.

The page looks like this:

User Control in ASP.NET is extremely important in case when developer wants to use a control repeatedly in many pages, it can just be dragged down from the solution explorer.

Now I’ll come to the code part:

<uc1:SectionLevelTutorialListing ID=”SectionLevelTutorialListing1″
runat=”server” />

  • This elements come automatically to the Default.aspx.
  • Next Code of creating User Control:
  • <%@ Control Language=”C#” AutoEventWireup=”true” CodeFile=”SectionLevelTutorialListing.ascx.cs” Inherits=”UserControls_SectionLevelTutorialListing” %>
    <asp:Repeater ID=”TutorialList” runat=”server” EnableViewState=”False”>
    <li><asp:HyperLink ID=”HyperLink1″ runat=”server”
    NavigateUrl='<%# Eval(“Url”) %>’
    Text='<%# Eval(“Title”) %>’></asp:HyperLink>
    – <%# Eval(“Description”) %></li>
  • The next part of Data Binding the User Control to the SiteMap.:
  • protected void Page_Load(object sender, EventArgs e)
    // If SiteMap.CurrentNode is not null,
    // bind CurrentNode ChildNodes to the GridView
    if (SiteMap.CurrentNode != null)
    TutorialList.DataSource = SiteMap.CurrentNode.ChildNodes;


    The actual code and everything I got from Scott Mitchel’s very useful database tutorial.

  • Read Scott Mitchel

    To prevent hackers in PHP


    I was attracted to dynamic web language like PHP and later on ASP.NET for the sake of its interactivity.

    To do that user input is extremely important. Basically it’s done by taking user’s input through text boxes and after that a click on a button posts that texts to server to do the rest of the tricks.

    But there is a thin line exists between a good user and a bad user. Someone might try to inject some malicious codes through text boxes to the server and that would ultimately attack the data bank of the site.

    What can be done?

    In ASP.NET, it’s done differently.

    In PHP, today I found str_tags() function which can do the magic.

    Let me see the pages first, how it looks:

    We tried to inject <b></b> code but the result comes out as:

    Now the code part:

    • <?php


      function handle_data()

      echo “Your name is : “;
      $text = strip_tags($_REQUEST[“name”]);
      echo $text;



    • I did not mention the HTML part as it was quite evident, the input was taken from the textbox.

    How is Life?


    Well, a little bit deviation from the world of  Web Programming. Let me tackle this question in a different way.

    Am I happy now?

    Yes, I am.

    How about this present moment?

    Very nice. I have no complain. I am happy with what I have got. I want to live this present moment earnestly and wisely. I don’t dwell in my past.

    Oh, yes, when I think about the happiest past moments, I often tend to become inclined to think that those past moments were great than now! But, in such cases, I always think that, since it was past and no chance of replaying the past same again, so it is nothing but illusion of happiness.

    Never glorify the past than it was. And I never dream about a future that will have gone out of my present moment’s reach!

    My present happy moments are my biggest wealth.