Entries Tagged as ''

The SqlCommand Object database operations C# dot net

The SqlCommand Object

This lesson describes the SqlCommand object and how you use it to interact with a data base. Here are the objectives of this lesson:

  • Know what a command object is.
  • Learn how to use the ExecuteReader method to query data.
  • Learn how to use the ExecuteNonQuery method to insert and delete data.
  • Learn how to use the ExecuteScalar method to return a single value.

Introduction

A SqlCommand object allows you to specify what type of interaction you want to perform with a data base. For example, you can do select, insert, modify, and delete commands on rows of data in a data base table. The SqlCommand object can be used to support disconnected data management scenarios, but in this lesson we will only use the SqlCommand object alone. A later lesson on the SqlDataAdapter will explain how to implement an application that uses disconnected data. This lesson will also show you how to retrieve a single value from a data base, such as the number of records in a table.

Creating a SqlCommand Object

Similar to other C# objects, you instantiate a SqlCommand object via the new instance declaration, as follows:

SqlCommand cmd = new SqlCommand(“select CategoryName from Categories”, conn);

The line above is typical for instantiating a SqlCommand object. It takes a string parameter that holds the command you want to execute and a reference to a SqlConnection object. SqlCommand has a few overloads, which you will see in the examples of this tutorial.

Querying Data

When using a SQL select command, you retrieve a data set for viewing. To accomplish this with a SqlCommand object, you would use the ExecuteReader method, which returns a SqlDataReader object. We’ll discuss the SqlDataReader in a future lesson. The example below shows how to use the SqlCommand object to obtain a SqlDataReader object:

// 1. Instantiate a new command with a query and connection
SqlCommand cmd =
new SqlCommand(“select CategoryName from Categories”, conn);

// 2. Call Execute reader to get query results
SqlDataReader rdr = cmd.ExecuteReader();

In the example above, we instantiate a SqlCommand object, passing the command string and connection object to the constructor. Then we obtain a SqlDataReader object by calling the ExecuteReader method of the SqlCommand object, cmd.

This code is part of the ReadData method of Listing 1 in the Putting it All Together section later in this lesson.

Inserting Data

To insert data into a data base, use the ExecuteNonQuery method of the SqlCommand object. The following code shows how to insert data into a data base table:

// prepare command string
string insertString = @”
insert into Categories
(CategoryName, Description)
values (‘Miscellaneous’, ‘Whatever doesn”t fit elsewhere’)”;

// 1. Instantiate a new command with a query and connection
SqlCommand cmd = new SqlCommand(insertString, conn);

// 2. Call ExecuteNonQuery to send command
cmd.ExecuteNonQuery();

The SqlCommand instantiation is just a little different from what you’ve seen before, but it is basically the same. Instead of a literal string as the first parameter of the SqlCommand constructor, we are using a variable, insertString. The insertString variable is declared just above the SqlCommand declaration.

Notice the two apostrophes (”) in the insertString text for the word “doesn”t”. This is how you escape the apostrophe to get the string to populate column properly.

Another observation to make about the insert command is that we explicitly specified the columns CategoryName and Description. The Categories table has a primary key field named CategoryID. We left this out of the list because SQL Server will add this field itself. trying to add a value to a primary key field, such as CategoryID, will generate an exception.

To execute this command, we simply call the ExecuteNonQuery method on the SqlCommand instance, cmd.

This code is part of the Insertdata method of Listing 1 in the Putting it All Together section later in this lesson.

Updating Data

The ExecuteNonQuery method is also used for updating data. The following code shows how to update data:

// prepare command string
string updateString = @”
update Categories
set CategoryName = ‘Other’
where CategoryName = ‘Miscellaneous’”;

// 1. Instantiate a new command with command text only
SqlCommand cmd = new SqlCommand(updateString);

// 2. Set the Connection property
cmd.Connection = conn;

// 3. Call ExecuteNonQuery to send command
cmd.ExecuteNonQuery();

Again, we put the SQL command into a string variable, but this time we used a different SqlCommand constructor that takes only the command. In step 2, we assign the SqlConnection object, conn, to the Connection property of the SqlCommand object, cmd.

This could have been done with the same constructor used for the insert command, with two parameters. It demonstrates that you can change the connection object assigned to a command at any time.

The ExecuteNonQuery method performs the update command.

This code is part of the UpdateData method of Listing 1 in the Putting it All Together section later in this lesson.

Deleting Data

You can also delete data using the ExecuteNonQuery method. The following example shows how to delete a record from a data base with the ExecuteNonQuery method:

// prepare command string
string deleteString = @”
delete from Categories
where CategoryName = ‘Other’”;

// 1. Instantiate a new command
SqlCommand cmd = new SqlCommand();

// 2. Set the CommandText property
cmd.CommandText = deleteString;

// 3. Set the Connection property
cmd.Connection = conn;

// 4. Call ExecuteNonQuery to send command
cmd.ExecuteNonQuery();

This example uses the SqlCommand constructor with no parameters. Instead, it explicity sets the CommandText and Connection properties of the SqlCommand object, cmd.

We could have also used either of the two previous SqlCommand constructor overloads, used for the insert or update command, with the same result. This demonstrates that you can change both the command text and the connection object at any time.

The ExecuteNonQuery method call sends the command to the data base.

This code is part of the DeleteData method of Listing 1 in the Putting it All Together section later in this lesson.

Getting Single values

Sometimes all you need from a data base is a single value, which could be a count, sum, average, or other aggregated value from a data set. Performing an ExecuteReader and calculating the result in your code is not the most efficient way to do this. The best choice is to let the data base perform the work and return just the single value you need. The following example shows how to do this with the ExecuteScalar method:

// 1. Instantiate a new command
SqlCommand cmd = new SqlCommand(“select count(*) from Categories”, conn);

// 2. Call ExecuteNonQuery to send command
int count = (int)cmd.ExecuteScalar();

The query in the SqlCommand constructor obtains the count of all records from the Categories table. This query will only return a single value. The ExecuteScalar method in step 2 returns this value. Since the return type of ExecuteScalar is type object, we use a cast operator to convert the value to int.

This code is part of the GetNumberOfRecords method of Listing 1 in the Putting it All Together section later in this lesson.

Putting it All Together

For simplicity, we showed snippets of code in previous sections to demonstrate the applicable techniques . It is also useful to have an entire code listing to see how this code is used in a working program. Listing 1 shows all of the code used in this example, along with a driver in the Main method to produce formatted output.

Listing 1. SqlConnection Demo

using System;
using System.Data;
using System.Data.SqlClient;

/// <summary>
///
Demonstrates how to work with SqlCommand objects
/// </summary>
class SqlCommandDemo
{
SqlConnection conn;

public SqlCommandDemo()
{
// Instantiate the connection
conn = new SqlConnection(
“Data Source=(local);Initial Catalog=Northwind;Integrated Security=SSPI”);
}

// call methods that demo SqlCommand capabilities
static void Main()
{
SqlCommandDemo scd = new SqlCommandDemo();

Console.WriteLine();
Console.WriteLine(“Categories Before Insert”);
Console.WriteLine(“————————”);

// use ExecuteReader method
scd.ReadData();

// use ExecuteNonQuery method for Insert
scd.Insertdata();
Console.WriteLine();
Console.WriteLine(“Categories After Insert”);
Console.WriteLine(“——————————”);

scd.ReadData();

// use ExecuteNonQuery method for Update
scd.UpdateData();

Console.WriteLine();
Console.WriteLine(“Categories After Update”);
Console.WriteLine(“——————————”);

scd.ReadData();

// use ExecuteNonQuery method for Delete
scd.DeleteData();

Console.WriteLine();
Console.WriteLine(“Categories After Delete”);
Console.WriteLine(“——————————”);

scd.ReadData();

// use ExecuteScalar method
int numberOfRecords = scd.GetNumberOfRecords();

Console.WriteLine();
Console.WriteLine(“Number of Records: {0}”, numberOfRecords);
}

/// <summary>
/// use ExecuteReader method
/// </summary>
public void ReadData()
{
SqlDataReader rdr = null;

try
{
// Open the connection
conn.Open();

// 1. Instantiate a new command with a query and connection
SqlCommand cmd = new SqlCommand(“select CategoryName from Categories”, conn);

// 2. Call Execute reader to get query results
rdr = cmd.ExecuteReader();

// print the CategoryName of each record
while (rdr.Read())
{
Console.WriteLine(rdr[0]);
}
}
finally
{
// close the reader
if (rdr != null)
{
rdr.Close();
}

// Close the connection
if (conn != null)
{
conn.Close();
}
}
}

/// <summary>
/// use ExecuteNonQuery method for Insert
/// </summary>
public void Insertdata()
{
try
{
// Open the connection
conn.Open();

// prepare command string
string insertString = @”
insert into Categories
(CategoryName, Description)
values (‘Miscellaneous’, ‘Whatever doesn”t fit elsewhere’)”;

// 1. Instantiate a new command with a query and connection
SqlCommand cmd = new SqlCommand(insertString, conn);

// 2. Call ExecuteNonQuery to send command
cmd.ExecuteNonQuery();
}
finally
{
// Close the connection
if (conn != null)
{
conn.Close();
}
}
}

/// <summary>
/// use ExecuteNonQuery method for Update
/// </summary>
public void UpdateData()
{
try
{
// Open the connection
conn.Open();

// prepare command string
string updateString = @”
update Categories
set CategoryName = ‘Other’
where CategoryName = ‘Miscellaneous’”;

// 1. Instantiate a new command with command text only
SqlCommand cmd = new SqlCommand(updateString);

// 2. Set the Connection property
cmd.Connection = conn;

// 3. Call ExecuteNonQuery to send command
cmd.ExecuteNonQuery();
}
finally
{
// Close the connection
if (conn != null)
{
conn.Close();
}
}
}

/// <summary>
/// use ExecuteNonQuery method for Delete
/// </summary>
public void DeleteData()
{
try
{
// Open the connection
conn.Open();

// prepare command string
string deleteString = @”
delete from Categories
where CategoryName = ‘Other’”;

// 1. Instantiate a new command
SqlCommand cmd = new SqlCommand();

// 2. Set the CommandText property
cmd.CommandText = deleteString;

// 3. Set the Connection property
cmd.Connection = conn;

// 4. Call ExecuteNonQuery to send command
cmd.ExecuteNonQuery();
}
finally
{
// Close the connection
if (conn != null)
{
conn.Close();
}
}
}

/// <summary>
/// use ExecuteScalar method
/// </summary>
/// <returns>number of records</returns>
public int GetNumberOfRecords()
{
int count = -1;

try
{
// Open the connection
conn.Open();

// 1. Instantiate a new command
SqlCommand cmd = new SqlCommand(“select count(*) from Categories”, conn);

// 2. Call ExecuteNonQuery to send command
count = (int)cmd.ExecuteScalar();
}
finally
{
// Close the connection
if (conn != null)
{
conn.Close();
}
}
return count;
}
}

In Listing 1, the SqlConnection object is instantiated in the SqlCommandDemo structure. This is okay because the object itself will be cleaned up when the CLR garbage collector executes. What is important is that we close the connection when we are done using it. This program opens the connection in a try block and closes it in a finally block in each method.

The ReadData method displays the contents of the CategoryName column of the Categories table. We use it several times in the Main method to show the current status of the Categories table, which changes after each of the insert, update, and delete commands. Because of this, it is convenient to reuse to show you the effects after each method call.


Getting Post, Redirect, Get data Dot Net Forms getting started

Asp Dot Net Web Forms

A normal ASP.NET Web Form Lifecycle has the following pattern

  1. HTTP GET of “Create.aspx”
  2. HTTP POST of “Create.aspx”
  3. Validation Fails, “Create.aspx” is Re-Rendered
  4. HTTP POST of “Create.aspx”
  5. Item is created, “Create.aspx” is Re-Rendered with confirmation message

The major problems with this Postback pattern, is that hitting the Refresh button of your browser in steps 3 or 5 will re-post your submitted data. Step 5 is more of a problem as it could possibly re-submit that created information. Granted, there are steps that you can take to approach this problem, but this is how default ASP.NET Web Forms are treated.

Taking this same approach within ASP.NET MVC, can be achieved in the same manner by rendering a your “Create” view from your POST action. For example:

  1. HTTP GET of “/products/create”, “Create” view is rendered
  2. HTTP POST to “/products/submit”
  3. Validation Fails, “Create” view is rendered
  4. HTTP POST to “/products/submit”
  5. Item is created, “Confirm” view is rendered

As you’ll notice, the same problems we had with ASP.NET Web Forms exists with ASP.NET MVC. The really nice option, is that ASP.NET MVC gives you a lot more “freedom” of how the workflow is processed. If we strictly follow the PRG pattern within ASP.NET MVC, it would look something like

  1. HTTP GET of “/products/create”, “Create” view is rendered
  2. HTTP POST to “/products/submit”
  3. Validation Fails, redirect to “/products/create”, “Create” view is rendered
  4. HTTP POST to “/products/submit”
  5. Item is created, redirect to “/products/confirm”, “Confirm” view is rendered

As you’ll notice, where we previously could have had issues in step 3 or 5 before, we no longer have issues. If a user presses the Refresh button in either of those steps, they’ll not get the lovely “Would you like to resubmit the form data” confirmation as featured below – instead, the page just reloads.

image

To implement this, you’ll need 1 controller, 3 action methods, and 2 views. Follow the steps below to achieve this pattern:

   1:  using System.Web.Mvc;
   2:  
   3:  public class ProductsController : Controller
   4:  {
   5:     public ActionResult Create() { ... }
   6:     public ActionResult Submit() { ... }
   7:     public ActionResult Confirm() { ... }
   8:  }

When you implement your Create action, you have to keep in mind that validation may fail and you may need to re-display the form. TempData is best suited for this scenario, and is implemented as such.

   1:  public ActionResult Create()
   2:  {
   3:     if (TempData["ErrorMessage"] != null)
   4:     {
   5:        ViewData["ErrorMessage"] = TempData["ErrorMessage"];
   6:        ViewData["Name"] = TempData["Name"];
   7:        ViewData["Price"] = TempData["Price"];
   8:        ViewData["Quantity"] = TempData["Quantity"];
   9:     }
  10:     return RenderView();
  11:  }

Next you’ll implement your Submit action. This will perform some validation of the user input data, and if successful will save the info and redirect to the Confirm action. If it is not successful, we’ll store the form data into the TempData and redirect to the action Create. This way we mimic maintaining the view’s state even if it fails.

   1:  public ActionResult Submit()
   2:  {
   3:      string error = null;
   4:      string name = Request.Form["Name"];
   5:      if (string.IsNullOrEmpty(name))
   6:      {
   7:          error = "Name is empty. ";
   8:      }
   9:      decimal price;
  10:      if (!decimal.TryParse(Request.Form["Price"], out price))
  11:      {
  12:          error += "Price is invalid. ";
  13:      }
  14:      int quantity;
  15:      if (!int.TryParse(Request.Form["Quantity"], out quantity))
  16:      {
  17:          error += "Quantity is invalid.";
  18:      }
  19:  
  20:      if (!string.IsNullOrEmpty(error))
  21:      {
  22:          TempData["ErrorMessage"] = error;
  23:          TempData["Name"] = Request.Form["Name"];
  24:          TempData["Price"] = Request.Form["Price"];
  25:          TempData["Quantity"] = Request.Form["Quantity"];
  26:          return RedirectToAction("Create");
  27:      }
  28:      else
  29:      {
  30:          return RedirectToAction("Confirm");
  31:      }
  32:  }

Something very interesting to note in the above example, is that even though I’ve pulled all values out of the form into local variables, should either Price or Quantity fail in parsing and I set the TempData to the local variables…I would have lost the user input. So, it’s always a smart idea to retrieve the data from the form directly into the TempData. Finally, the Confirm action needs to be implemented.

   1:  public ActionResult Confirm()
   2:  {
   3:      return RenderView();
   4:  }

Now, it’s time to create our views:

~/Views/Products/Create.aspx

   1:  <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Create.aspx.cs" Inherits="Views_Products_Create" %>
   2:  <html xmlns="http://www.w3.org/1999/xhtml">
   3:  <head runat="server">
   4:      <title>Create Product</title>
   5:  </head>
   6:  <body>
   7:      <% using (Html.Form<ProductsController>(c => c.Submit())) { %>
   8:      <% if (!string.IsNullOrEmpty((string) ViewData["ErrorMessage"])) { %>
   9:          <div style="color:Red;">
  10:              <%= ViewData["ErrorMessage"] %>
  11:          </div>
  12:      <% } %>
  13:      Name: <%= Html.TextBox("Name", ViewData["Name"]) %><br />
  14:      Price: <%= Html.TextBox("Price", ViewData["Price"]) %><br />
  15:      Quantity: <%= Html.TextBox("Quantity", ViewData["Quantity"]) %><br />
  16:      <%= Html.SubmitButton("submitButton", "Save") %>
  17:      <% } %>
  18:  </body>
  19:  </html>

~/Views/Products/Confirm.aspx

   1:  <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Confirm.aspx.cs" Inherits="Views_Products_Confirm" %>
   2:  <html xmlns="http://www.w3.org/1999/xhtml">
   3:  <head id="Head1" runat="server">
   4:      <title>Confirm Create Product</title>
   5:  </head>
   6:  <body>
   7:      Thanks for creating your product.
   8:      <%= Html.ActionLink<ProductsController>(c => c.Create(), "Click here") %> to create a new one.
   9:  </body>
  10:  </html>

Easy payments using Paypal IPN,Using Paypal in PHP

There are several PHP scripts and classes to process PayPal payments using their native IPN (Internet payment notification) feature. Because the whole process is based on the data you need to send via a web form to the PayPal payment processor these script look very similar.

Inside the form there are several required values to process a payment. PayPal gives the advice to post them all to get everything working. The following variables get some special attention:

business = your PayPal email address
cmd = single payments or subscription service (_xclick or _xclick-subscriptions)
return = the URL where the buyer get back after the payment is processed
cancel_return = the URL where the buyer get back if he has cancelled the payment
notify_url = the location where your IPN script is located
rm = how you need the data submitted from PayPal to your IPN script (1=get, 2=post)
currency_code = the currency you accept for your payment
lc = the country version of PayPal where your buyer is send to

<?php
$url
= ‘https://www.paypal.com/cgi-bin/webscr’;
$postdata = ;
foreach(
$_POST as $i =&gt; $v) {
$postdata .= $i.‘=’.urlencode($v).‘&amp;’;
}
$postdata .= ‘cmd=_notify-validate’; $web = parse_url($url);
if (
$web[’scheme’] == ‘https’) {
$web[‘port’] = 443;
$ssl = ’ssl://’;
} else {
$web[‘port’] = 80;
$ssl = ;
}
$fp = @fsockopen($ssl.$web[‘host’], $web[‘port’], $errnum, $errstr, 30);if (!

$fp) {
echo
$errnum.‘: ’.$errstr;
} else {
fputs($fp, “POST ”.$web[‘path’].“ HTTP/1.1rn”);
fputs($fp, “Host: ”.$web[‘host’].“rn”);
fputs($fp, “Content-type: application/x-www-form-urlencodedrn”);
fputs($fp, “Content-length: ”.strlen($postdata).“rn”);
fputs($fp, “Connection: closernrn”);
fputs($fp, $postdata . “rnrn”);while(!

feof($fp)) {
$info[] = @fgets($fp, 1024);
}
fclose($fp);
$info = implode(‘,’, $info);
if (
eregi(‘VERIFIED’, $info)) {
// yes valid, f.e. change payment status
} else {
// invalid, log error or something
}
}

?>


Using SEO,Common SEO facts and Myths Starting with SEO

After 1Y0-259 and EX0-101, all those PMI-001 professionals who wrote 642-825 say that they could not have done it without credits like 642-436 and 642-845.

SEO common facts

The Internet has many SEO myths flying around, many of which only survive as nobody acknowledges them as being wrong, Until now. I have plucked out 5 of the Internets best SEO myths to share with you today.

Here are 5 SEO Myths of my choice:

  1. You have to submit your website URL to Google in order to be ranked in the Search Engine Results Pages (SERP). – This has not been the case for many years.
  2. You have to update your website regularly in order to rank well. – This may only serve to increase your crawl rate but will have no effect on how your pages rank in the SERP.
  3. H1 tags are mandatory to reach top spot in SERP. – This is one of the myths that I have checked out alot, and it seems if your check alot of sites that rank highly on the SERP’s they do not contain H1 tags. But I believe that you should use them anyway as they do not hurt your site.
  4. You need to use a Google Sitemap to rank well. – I believe that if you have built your site correctly and it can be crawled then the Google Sitemap is only of use if you wish to use the Google Webmaster Tools.
  5. You have to use the META Keywords in your pages content. – The META Keywords were designed to add extra keywords to your site that were not mentioned in the content. The fact is that Google ignores this attribute anyway so it makes no difference.

If u want to add more or want to have suggestions then feel free to post your reply.


SEO defination Explaination and HElp for SEO terms

Utilizing free web hosting is alright to the extent that one makes use of adsl as well related jobs, particularly when associated with advertising agencies.

Few Questions:-

Do you run a website and often hear other website owners talking about their SEO tactics and realise that you have no idea what SEO is, or how you go about it? Well you have come to the right place, we will give you all the information you need to understand what other website owners are talking about and help you to get a good understanding of Search Engine Optimization (SEO).
What is SEO?

Search Engine Optimization is a practice under taken by website owners who wish increase the amount of traffic they receive from search engines. It works by improving internal and external factors in order to achieve a higher position in search engine results pages (SERPs). By achieving a higher ranking in SERPs you can obtain more traffic for the keyword searched. As you can imagine there are usually hundreds of sites fighting it out for the top search engine rankings, so website owners compete with each other to optimise their site so that they can gain the advantage over their competitors.

Do You Need To Use SEO?

SEO can often be a time consuming process and I have heard many webmasters ask the question ‘Do I Really Need SEO?’. The real question that should be asked is ‘Do I Want People To Visit My Website?’. You could have a great website and spend all your time adding to it, but if no-one is visiting it, is it worth it?

The fact is that when people what to find something on the Internet, they will search for it on search engines. If your website is not listed or is low on the SERPs then it is likely that you are not getting the most from your website.

The bottom line is, search engine traffic can make or break your site, so investing time or money in SEO is a must for anyone wishing to have a successful website.

As you should now understand SEO should be done by any website owner who wants to receive high levels of high quality traffic.

It is possible to receive traffic from search engines without performing any SEO, but by performing some of the basic SEO tips you can vastly increase your websites traffic.

We hope you now understand what SEO is and the impact it can have on your site.


Mail Yourself When Google Crawls Your Site php SEo notification

Many web hosting companies are now offering pay per click as well as other marketing methods along with domain names without having the necessary education.

PHP: Mail Yourself When Google Crawls Your Site

Search engines like Google crawls sites from database.Means they have a list of websites in their database for checking and a script suns every specified time to check the listed web sites.You may need sometimes to notify about this event.

Have you ever wanted to know when Google crawls your website? Well now you can using a simple PHP script which emails you every time GoogleBot crawls your site.

I thought that many of you might find this bit of code useful, that is why I have decided to post it up.

It is not a very long piece of code, but I will talk you through how it functions.

First off lets take a look at the code:

  1. <?php
  2. if ( strpos( $_SERVER['HTTP_USER_AGENT'], ‘Googlebot’ ) !== false )
  3. {
  4. // Your email address
  5. $email_address = ‘you@yourdomain.com’;
  6. // Send yourself an email
  7. mail($email_address,’Googlebot Visit Alert’, ‘The Googlebot has visited your page: ‘.$_SERVER['REQUEST_URI'].” at time:”.time());
  8. }
  9. ?>

As you can see it is a simple piece of code.

First of all it checks the user agent to see if it is ‘Googlebot’. If the user agent is ‘Googlebot’ then it will send an email to the email address you supply.


Developing web sites Getting started with web Developement

Requirements before getting started with development or web programming

Any one who want to develop a web application must have the following systems:

1. A web server.
2. An editor to develop the web pages.
3. A browser to view the web page you develop.
4. A database program like MS Access, SQL Server etc, if your web site need to save data into a database.

In the real world situation, a web server will be hosted on a secure server, located in a safe place and will be always connected to high speed internet. However, to develop a web application, you don’t need to worry about security and internet connectivity. You can use your own development computer as the ‘Web Server’.

So, your development computer must have all the 4 program’s mentioned above running well.

Since this tutorial is guiding you to develop web sites using ASP.NET, all the tools we are going to talk here will be the ASP.NET specific tools.

Web Server

There are several types of web servers. But if you like to develop ASP.NET web applications, you need a specific web server called ‘Internet Information Server’ (IIS). And if you like to develop your web site using PHP then i will prefer you to use apache web server.

IIS comes as part of Windows. But it is not installed by default, when you install Windows. Please see the chapter ‘Installing IIS‘ to find more about installing IIS. IIS can be configured to work with PHP.But for PHP technologies Apache with LINUX is prefered.

Editor to develop web pages

Ideally, you do not need any special editor to develop a web application. If you are an expert, you can simply use ntoepad to type HTML and the code for the web pages.

You don’t need to work too on basics so Microsoft gives a tool called ‘Visual Studio .NET’ to edit web pages and write code for ASP.NET.

In case of other technologies then you can get EditPlus,Nusphere PHPed, Dreamweawear etc.You can just search on google for free programming editor and you will get a list :)

Visual Studio .NET (VS.NET)

Visual Studio .NET allows to easily create web pages. Some of the benefits in using Visual Studio .NEt are:

  • You can simply drag and drop html controls to the web page and VS.NET will automatically write the HTML tags for you.
  • Start typing an HTML tag and VS.NET will complete it! When you start typing a tag, VS.NET will show you the HTML tags starting with the characters you typed. So, you don’t need to even remember all the tags.
  • If you type any HTML tags wrong, VS.NET will highlight the errors and tell you how to correct it.

So, even if you are not an expert, VS.NET can help you develop great web pages.

Browser

You need a browser to view the web pages you create. If you have any windows operating system in your computer, you will already have a free browser (called ‘Internet Explorer’).You can also download and install other web browsers like Mozilla Firefox and Netscape navigator or Opera.Just search for any of keyword like Opera,Firefox and you will get a long listing.I will prefer you to have at least three browsers but having Mozilla’s and IE6 is better combination for testing and development purpose.

Database program

A database program like MS Access or SQL Server or SQL Express is required only if you need to save data into database. It is not mandatory that all web sites need a database program.But if you want to have a nice dynamic site then i will prefer to make use of databases.It greatly can reduce your file system load by keeping most of data in database and so will result interactive and dynamic web sites.Most of web sites these days are database driven.

For PHP users the suggested database is MySQL. You can get this free from mysql.com web site.

Downloading Required Softwares:-(PHP users)

In case you want to use PHP for web development then you can easily download You required softwares from internet.You can choose any of pref red one fromhere:-

  • WAMP (Window Apache MySQL PHP) combination of all of Window Apache MySQL PHP.Freely can be downloaded from internet.Search for WAMP and download this.
  • XAMP Same like WAMP integrates all tools like MYsql Apache into a common space.
  • Download Apache from apache.net,Mysql from mysql.com and install them seperatly.

What is a Web browser? Understanding and explaining term “Web Browser”

Few Definitions for browser:-

  • Browser is an application, which helps us to view the Web sites and the web content.
  • Web sites are located in some remote systems, which needs a special kind of program or an application to access them, such an application is called browser.
  • A browser is an application which you can use to retrieve web pages from web sites and view.
  • When you type a URL in the browser, the browser will convert it into a web request which web server can understand. Browser will send the request to web server using the HTTP protocol.
  • When a web server returns a web page as a Response, the browser will understand the response and display the body of the response to the user in browser.
  • In simple terms a browser can be defined as “A software application used to locate and display Web pages”
  • You can create your own simple browser application using C++, C#, VB.NET or any other language you like. All you need to know is, how to compose a request which web server can understand, how to parse and display the response from web server and communicate with webserver using HTTP protocol.
  • Even though the basic job of browser is just send requests to web server and receive response from the server, modern browser provide several other enhanced features including Back/Forward buttons, save viewed files to disk so that they can be viewed later, cache images so that the same images need not be downloaded again and again etc.
  • Internet Explorer, Netspace, Mozilla are some of the popular web browsers currently available in the market.
  • Netscape was the most popular web browser till 4-5 years back, but currently more than 90% of the internet users use “Internet Explorer” to browse the websites.

Understanding web server and its workings

For search engine optimization, every thing counts, from the clarity of web design, to the relevance of email marketing as well as the quality and reliability of hosting.

What is a web server?

A Web server is a software program which serves web pages to web users (browsers).

A web server delivers requested web pages to users who enter the URL in a web browser. Every computer on the Internet that contains a web site must have a web server program.

The computer in which a web server program runs is also usually called a “web server”. So, the term “web server” is used to represent both the server program and the computer in which the server program runs.

Characteristics of web servers

A web server computer is just like any other computer. The basic characteristics of web servers are:

- It is always connected to the internet so that clients can access the web pages hosted by the web server.
- It has an application called ‘web server’ running always.

In short, a ‘web server’ is a computer which is connected to the internet/intranet and has a software called ‘web server’. The web server program will be always running in the computer. When any user try to access a website hosted by the web server, it is actually the web server program which delivers the web page which client asks for.

All web sites in the internet are hosted in some web servers sitting in different parts of the world.

Web Server is a hardware or a software ?

From the above definition, you must have landed up in confusion “Web server is a hardware or a software”

Mostly, Web server refers to the software program, which serves the clients request. But as we mentioned earlier in this chapter, the computer in which the web server program is also called ‘web server”.

Web Server – Behind the Scene

Now that you are reading this page, have you ever had a thought how the page is made available to the browser?

Your answer would be, “I typed in the URL http://www.aspspider.com and clicked on some link, I dropped into this page.”

But what happed behind the scenes to bring you to this page and make you read this line of text.

So now, lets see what is actually happening behind the scene. The first you did is, you typed the URL http://www.aspspider.com in the address bar of your browser and pressed your return key.

We could break this URL into two parts,

  1. The protocol we are going to use to connect to the server (http)
  2. The server name (www.aspspider.com)

The browser breaks up the URL into these parts and then it tries to communicate with the server looking up for the server name. Actually, server is identified through an IP address but the alias for the IP address is maintained in the DNS Server or the Naming server. The browser looks up these naming servers, identifies the IP address of the server requested and gets the site and gets the HTML tags for the web page. Finally it displays the HTML Content in the browser.

Where is my web server ?

When you try to access a web site, you don’t really need to know where the web server is located. The web server may be located in another city or country, but all you need to do is, type the URL of the web site you want to access in a web browser. The web browser will send this information to the internet and find the web server. Once the web server is located, it will request the specific web page from the webserver program running in the server. Web server program will process your request and send the resulting web page to your browser. It is the responsibility of your browser to format and display the webpage to you.

How many web servers are needed for a web site?

Typically, there is only one web server required for a web site. But large web sites like Yahoo, Google, MSN etc will have millions of visitors every minute. One computer cannot process such huge numbers of requests. So, they will have hundreds of servers deployed in different parts of the world so that can provide a faster response.

How many websites can be hosted in one server?

A web server can hosted hundreds of web sites. Most of the small web sites in the internet are hosted on shared web servers. There are several web hosting companies who offer shared web hosting. If you buy a shared web hosting from a web hosting company, they will host your web site in their web server along with several other web sites for a Fee.

Examples of web server applications

1. IIS
2. Apache

Find definition for ‘Web Server’ in Google:

http://www.google.com/search?hl=en&lr=&rls=GGLD,GGLD:2005-08,GGLD:en&oi=defmore&q=define:Web+Server