Monday, April 25, 2011

How to read XML from a file


How to read XML from a file
This example uses a file named Books.xml. You can create your own Books.xml file or use the sample file that is included with the .NET Software Development Kit (SDK) QuickStarts in the following folder:
\Program Files\Microsoft Visual Studio .NET\FrameworkSDK\Samples\QuickStart\Howto\Samples\Xml\Transformxml\Cs
You must copy Books.xml to the \Bin\Debug folder, which is located under the folder in which you create this project. Books.xml is also available for download. See to the "References" section for the download location.
Start Visual Studio 2005 or Visual Studio .NET.
Create a new Visual C# Console Application. You proceed directly to the "Complete code listing" section or continue through these steps to build the application.
Make sure that the project contains a reference to the System.Xml.dll assembly.
Specify the using directive on the System.Xml namespace so that you are not required to qualify XmlTextReader declarations later in your code. You must use the using directive before any other declarations.
using System.Xml;

Create an instance of an XmlTextReader object, and populate it with the XML file. Typically, the XmlTextReader class is used if you need to access the XML as raw data without the overhead of a DOM; thus, the XmlTextReader class provides a faster mechanism for reading XML. The XmlTextReader class has different constructors to specify the location of the XML data. The following code creates an instance of the XmlTextReader class and loads the Books.xml file. Add the following code to the Main procedure of Class1.
XmlTextReader reader = new XmlTextReader ("books.xml");

Read through the XML. (Note that this step demonstrates an outer "while" loop, and the next two steps demonstrate how to use that loop to read the XML.) After you create the XmlTextReader object, use the Read method to read the XML data. The Read method continues to move through the XML file sequentially until it reaches the end of the file, at which point the Read method returns a value of "False."
while (reader.Read())
{
    // Do some work here on the data.
Console.WriteLine(reader.Name);
}
Console.ReadLine();

Inspect the nodes. To process the XML data, each record has a node type that can be determined from the NodeType property. The Name and Value properties return the node name (the element and attribute names) and the node value (the node text) of the current node (or record). The NodeType enumeration determines the node type. The following sample code displays the name of the elements and the document type. Note that this sample ignores element attributes.
while (reader.Read())
{
    switch (reader.NodeType)
    {
        case XmlNodeType.Element: // The node is an element.
            Console.Write("<" + reader.Name);
   Console.WriteLine(">");
            break;
  case XmlNodeType.Text: //Display the text in each element.
            Console.WriteLine (reader.Value);
            break;
  case XmlNodeType. EndElement: //Display the end of the element.
  

Saturday, April 23, 2011

C sharp Delegates and Events


All of us have been exposed to event driven programming of some sort or the other. C# adds on value to the often mentioned world of event driven programming by adding support through events and delegates. The emphasis of this article would be to identify what exactly happens when you add an event handler to your common UI controls. A simple simulation of what could possibly be going on behind the scenes when the AddOnClick or any similar event is added to the Button class will be explained. This will help you understand better the nature of event handling using multi cast delegates.
A delegate in C# is similar to a function pointer in C or C++. Using a delegate allows the programmer to encapsulate a reference to a method inside a delegate object. The delegate object can then be passed to code which can call the referenced method, without having to know at compile time which method will be invoked.
In most cases, when we call a function, we specify the function to be called directly. If the class MyClass has a function named Process, we'd normally call it like this (SimpleSample.cs):
using System;

namespace Akadia.NoDelegate
{
    public class
 MyClass
    {
        public void
 Process()
        {
            Console.WriteLine("Process() begin");
            Console.WriteLine("Process() end");
        }
    }

    public class Test
    {
        static void Main(string[] args)
        {
           
 MyClass myClass = new MyClass();
            myClass.
Process();
        }
    }
}
That works well in most situations. Sometimes, however, we don't want to call a function directly - we'd like to be able to pass it to somebody else so that they can call it. This is especially useful in an event-driven system such as a graphical user interface, when I want some code to be executed when the user clicks on a button, or when I want to log some information but can't specify how it is logged.
An interesting and useful property of a delegate is that it does not know or care about the class of the object that it references. Any object will do; all that matters is that the method's argument types and return type match the delegate's. This makes delegates perfectly suited for "anonymous" invocation.
The signature of a single cast delegate is shown below:
delegate result-type identifier ([parameters]);
where:
o    result-type: The result type, which matches the return type of the function.
o    identifier: The delegate name.
o    parameters: The Parameters, that the function takes.
Examples:
public delegate void SimpleDelegate ()
This declaration defines a delegate named SimpleDelegate, which will encapsulate an

Tuesday, April 19, 2011

Sql:How to create database in sql server 2005


Sql:How to create database in sql server 2005

CREATE DATABASE database_name

[ ON [ PRIMARY ]  [ <  filespec >] ]

{ LOG ON [ < filespec > ] ]

< filespec > : : =

( [ NAME = logical_file_name , ]

FILENAME = 'os_file_name'

[ , SIZE = size ]

[ , MAXSIZE = { max_size | UNLIMITED } ]

[ , FILEGROWTH = growth_increment ] ) [ ,.... n ]


Description ::-

ON specifies the disk file used to store the data portion of the database.

LOG ON specifies the disk files used to store log files.

Saturday, April 16, 2011

Social Networks.................

This company develop social networks also like Facebook.....Contact at www.ultimatumtechno.com...


Network Programming in C#


Network Programming in C#
 
(Page 1 of 2 )


The .NET framework provides two namespaces, System.Net and System.Net.Sockets for network programming. The classes and methods of these namespaces help us to write programs, which can communicate across the network. The communication can be either connection oriented or connectionless. They can also be either stream oriented or data-gram based. The most widely used protocol TCP is used for stream-based communication and UDP is used for data-grams based applications. 
The System.Net.Sockets.Socket is an important class from the System.Net.Sockets namespace. A Socket instance has a local and a remote end-point associated with it. The local end-point contains the connection information for the current socket instance. 
There are some other helper classes like IPEndPoint, IPADdress, SocketException etc, which we can use for Network programming. The .NET framework supports both synchronous and asynchronous communication between the client and server. There are different methods supporting for these two types of communication. 

A synchronous method is operating in blocking mode, in which the method waits until the operation is complete before it returns. But an asynchronous method is operating in non-blocking mode, where it returns immediately, possibly before the operation has completed.
Dns Class
The System.net namespace provides this class, which can be used to creates and send queries to obtain information about the host server from the Internet Domain Name Service (DNS). Remember that in order to access DNS, the machine executing the query must be connected to a network. If the query is executed on a machine, that does not have access to a domain name server, a System.Net.SocketException is thrown. All the members of this class are static in nature. The important methods of this class are given below. 
public static IPHostEntry GetHostByAddress(string address)
Where address should be in a dotted-quad format like "202.87.40.193". This method returns an IPHostEntry instance containing the host information. If DNS server is not available, the method returns a SocketException. 
public static string GetHostName()
This method returns the DNS host name of the local machine.
In my machine Dns.GetHostName() returns vrajesh which is the DNS name of my machine. 
public static IPHostEntry Resolve(string hostname)
This method resolves a DNS host name or IP address to a IPHostEntry instance. The host name should be in a dotted-quad format like 127.0.01 or www.microsoft.com. 
IPHostEntry Class
This is a container class for Internet host address information. This class makes no thread safety guarantees. The following are the important members of this class. 
AddressList Property
Gives an IPAddress array containing IP addresses that resolve to the host name. 
Aliases Property
Gives a string array containing DNS name that resolves to the IP addresses in AddressList property. 
The following program shows the application of the above two classes.
using System;
using System.Net;
using System.Net.Sockets;
class MyClient
{
            public static void Main()
            {
                        IPHostEntry IPHost = Dns.Resolve("www.hotmail.com");
                        Console.WriteLine(IPHost.HostName);
                        string []aliases = IPHost.Aliases;
                        Console.WriteLine(aliases.Length);
                        IPAddress[] addr = IPHost.AddressList;
                        Console.WriteLine(addr.Length);
                        for(int i= 0; i < addr.Length ; i++)
       

Network Example In C sharp


Network Example In C sharp
Developing applications in C# that access resource on the internet is easy. This post shows four useful functions: checking if the PC is connected to a network, domain name to IP address lookup, ping a host and download a file.



Network Availability

You can check if there are any network connections using NetworkInterface.GetIsNetworkAvailable static method, found in the System.Net.NetworkInformation assembly. MSDN: “A network connection is considered to be available if any network interface is marked “up” and is not a loopback or tunnel interface.” Here is how you could check for a network connection:
1.         if (!System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())  
2.         {  
3.             MessageBox.Show("There is no network connection available.",  
4.                 "NetworkTools", MessageBoxButtons.OK, MessageBoxIcon.Information);  
5.         }  

Host Name Lookup


To lookup a host name’s IP address or vice versa you could use the Dns.GetHostEntry static method in the System.Net assembly. It returns an IPHostEntry object th

Want Earn At Home Contact This Company..

C# Hashtable Use, Lookups and Examples


C# Hashtable Use, Lookups and Examples
Top of Form
Bottom of Form

You want to use the Hashtable collection in the best way, for either an older program written in the C# language or for maintaining a program. The Hashtable provides a fast and simple interface, in many ways simpler than Dictionary. Here we see how you can use the Hashtable collection in the C# programming language, providing a fast lookup collection for hashing keys to values in a constant-time data structure.
Create Hashtable and add entries
First here we see how you can create a new Hashtable with the simplest, parameterless constructor. When it is created, the Hashtable has no values, but we can directly assign values with the indexer, which uses the square brackets [ ]. The example adds three integer keys with one string value each.
Add entries to Hashtable and display them [C#]

using System;
using System.Collections;

class Program
{
    static void Main()
    {
        Hashtable hashtable = new Hashtable();
        hashtable[1] = "One";
    

C# List Examples


C# List Examples
Top of Form
You have questions about the List collection in the .NET Framework, which is located in the System.Collections.Generic namespace. You want to see examples of using List and also explore some of the many useful methods it provides, making it an ideal type for dynamically adding data. This document has lots of tips and resources on the List constructed type, with examples using the C# programming language.
Lists are dynamic arrays in the C# language.
They can grow as needed when you add elements.
They are considered generics and constructed types.
You need to use < and > in the List declaration.
Add values
To start, we see how to declare a new List of int values and add integers to it. This example shows how you can create a new List of unspecified size, and add four prime numbers to it. Importantly, the angle brackets are part of the declaration type, not conditional operators that mean less or more than. They are treated differently in the language.
Program that adds elements to List [C#]

using System.Collections.Generic;

class Program
{
    static void Main()
    {
        List<int> list = new List<int>();
        list.Add(2);
        list.Add(3);
        list.Add(5);

C sharp ArrayList Class


C# ArrayList Examples, Usage and Tips
Top of Form
You need to use the ArrayList class in an older C# program to fix or improve the dynamic arrays. ArrayList is still useful, even when newer classes are more durable and popular. Here we see examples and tips using the ArrayList class in the C# programming language, moving from the simpler tasks to the more advanced usages of ArrayList.
Add elements
The Add method on ArrayList is used in almost every program. It appends a new element object to the very end of the ArrayList. You can keep adding elements to your collection until memory runs out. The objects are stored in the managed heap.
Program that uses ArrayList [C#]

using System.Collections;

class Program
{
    static void Main()
    {
       //
       // Create an ArrayList and add three elements.
       //
       ArrayList list = new ArrayList();

Thursday, April 14, 2011

SQL: Local Temporary tables


SQL: Local Temporary tables


Local temporary tables are distinct within modules and embedded SQL programs within SQL sessions.
The basic syntax is:
DECLARE LOCAL TEMPORARY TABLE table_name ( ...);

SQL: Global Temporary tables


SQL: Global Temporary tables


Global temporary tables are distinct within SQL sessions.
The basic syntax is:
CREATE GLOBAL TEMPORARY TABLE table_name ( ...);

For example:
CREATE GLOBAL TEMPORARY TABLE supplier
(supplier_idnumeric(10)not null,
supplier_namevarchar(50)not null,
contact_namevarchar(50)
)
This would create a global temporary table called supplier .

SQL: Joins


SQL: Joins


join is used to combine rows from multiple tables. A join is performed whenever two or more tables is listed in the FROM clause of an SQL statement.
There are different kinds of joins. Let's take a look at a few examples.

Inner Join (simple join)

Chances are, you've already written an SQL statement that uses an inner join. It is the most common type of join. Inner joins return all rows from multiple tables where the join condition is met.
For example,
SELECT suppliers.supplier_id, suppliers.supplier_name, orders.order_date
FROM suppliers, orders
WHERE suppliers.supplier_id = orders.supplier_id;
This SQL statement would return all rows from the suppliers and orders tables where there is a matching s

SQL: ORDER BY Clause


SQL: ORDER BY Clause


The ORDER BY clause allows you to sort the records in your result set. The ORDER BY clause can only be used in SELECT statements.
The syntax for the ORDER BY clause is:
SELECT columns
FROM tables
WHERE predicates
ORDER BY column ASC/DESC;
The ORDER BY clause sorts the result set based on the columns specified. If the ASC or DESC value is omitted, it is sorted by ASC.
ASC indicates ascending order. (default)
DESC indicates descending order.

Example #1
SELECT supplier_city
FROM suppliers
WHERE supplier_name = 'IBM'
ORDER BY supplier_city;
This would return all records sorted by the supplier_city field in ascending order.

Example #2
SELECT supplier_city
FROM suppliers
WHERE supplier_name = 'IBM'
ORDER BY supplier_city DESC;
This would return all records sorted by the supplier_city field in descending order.

Example #3
You can also sort by relative position in the result set, where the first field in the result set is 1. The next field is 2, and so on.
SELECT supplier_city
FROM suppliers

Sql Select statement Example


SELECT Examples (Transact-SQL)

This topic provides examples of using the SELECT statement.

A. Using SELECT to retrieve rows and columns
The following example shows three code examples. This first code example returns all rows (no WHERE clause is specified) and all columns (using the *) from the Product table in the AdventureWorks2008R2 database.

 USE AdventureWorks2008R2;
GO
SELECT *
FROM Production.Product
ORDER BY Name ASC;
-- Alternate way.
USE AdventureWorks2008R2;
GO
SELECT p.*

Wednesday, April 13, 2011

Learn C sharp Gaming Chapter 7


Basics of Structures and Classes
In the olden days of computer programming, programming languages were quite simple,
and you could create only a limited number of variables. This, obviously, made programs
very limited and quite ugly, to boot. For example, you would be creating programs like the
following in an older language:
int SpaceshipArmor;
int SpaceshipPower;
int SpaceshipFuel;
int EnemyArmor;
int EnemyPower;
int EnemyFuel;
As you can imagine, this gets to be a tangled mess rather quickly, and makes it very difficult
to manage your code.

Using classes and structures makes your life easier by encapsulating data into an easy-to
use packet of data.
Creating Classes and Structures
Basically, the idea behind classes and structures is to create your very own kind of object
using pieces of what was already in the language. A structure is essentially a data type that
can hold other pieces of data inside of it, allowing you to build your own types of data; it
is sort of like a building block. For example, here’s a structure describing a simple spaceship
object in C#:
struct Spaceship
{
public int fuel;
public int armor;
public int power;
}

note

We build Web Sites And Softwares In all languages



We build web sites and softwares in any language .our cost doesn't matter for us.our client
is utmost priority for us. 

Wednesday, April 6, 2011

How to hack Facebook Account


Disclaimer: The following hacks or tweaks are not recommended to cause any damage or threat to other facebook users. The listed methods are not to compromise any facebook users accounts.
Hack or Tweak Facebook accounts for fun by using simple pieces of Javascript code.

Javascript Tweaks in Facebook Account

In these following tweaks we’ll be using basic Javascript to toy around with Facebook. Note that we’re not going to hack into Facebook accounts, or anything of the like. Most of these ‘hacks’ are temporary and will disappear once you refresh the page. They also won’t be visible to users on other computers. So why are we doing it? – Because it’s fun!
These Javascript snippets, which we’ll supply below, simply need to be pasted into the address bar. Hit enter.

Changing Profile Color

This will change the colour of your Facebook bar to a color of choice.

AngularJS Basics - Part 1

                                                                  AngularJS What is AngularJS ·          Framework by googl...