« September 2008 | Main | November 2008 »

October 2008 Archives

October 10, 2008

Larry @ Zdnet

It is about new HP server and storage technology with Oracle Database. It goes up to Exabyte space to cope with the information world today.

Oracle shows off new Exadata storage server
http://news.zdnet.com/2422-13568_22-236913.html

Oracle CEO launches 'world's fastest database machine
http://news.zdnet.com/2422-13568_22-236911.html

October 12, 2008

Write Table content from Database to XML file


I found the easiest way to write a table or even tables from database to XML file is in.NET languages. To do this in Java you might probably need to include not only one but few proprietary library or open source jar file.

 

To do this in C#, one of the .NET languages, there is no additional reference need to be added to the project. Only using System.Data is needed because of the Dataset.

 

The code segment that writes dataset to XML file as follow (the code segment is from MSDN library):

 

    static void WriteXmlToFile(DataSet thisDataSet)

    {

      if (thisDataSet == null) { return; }

 

      // Create a file name to write to.

      string filename = "XmlDoc.xml";

 

      // Create the FileStream to write with.

      System.IO.FileStream stream = new System.IO.FileStream

          (filename, System.IO.FileMode.Create);

 

      // Write to the file with the WriteXml method.

      thisDataSet.WriteXml(stream);

}

 

The complete code to extract the data from employee table of HR schema to XML from is in http://skydrive.live.com. The sample file name is ConsoleDatasettoXML .zip. My MSN ID is chanmmn@hotmail.com.

October 19, 2008

The myth of LINQ (simplest sample for ADO.NET Entity Data Model)


If you are a .NET fan out there then you will basically hearing from many people asking, I have ADO.NET 2.0 so why is there a LINQ? It was a myth to me too. After Microsoft launch Service Pack 1 for Visual Studio 2008 then I clear some of my cloud in my head.

I will only mention one of the unique features here, ADO.NET Entity Data Model from ADO.NET Entity Framework. I have not found a better way to bind the Entity Model to DataGridView web control.

In order to create ADO.NET Entity Data Model, right click either Windows Application Project or Web Application Project and choose Add New Item… . Select ADO.NET Entity Data Model from the Add New Item dialog. After that you will have a file with edmx extension.

I have created a complete Windows Application sample using Northwind database in MS SQL 2008 Express. The Entity named NorthwindEntities. The entire sample consisted of 2 controls, 1 DataGridView and another is Button. I only have few lines of code in Button click event as below.

 private void btnGetCustomers_Click(object sender, EventArgs e)

{

  NorthwindEntities nwe = new NorthwindEntities();

 

  var cus = from customer in nwe.Customers

            select customer;

 

  dataGridView1.DataSource = cus;

}

I guess no one will ever say this is difficult.

The complete code is in http://skydrive.live.com. The sample file name is WinAppEntities.rar. My MSN ID is chanmmn@hotmail.com.


Unfortunately, ADO.NET Entity Data Model is not working with Oracle Database yet.

October 25, 2008

Write a simple object to and from XML using C#


Write a simple object to and from XML using C#

Write to XML file is always easier than read from XML file. Not too sure what I mean, it is alright because I have a sample for you to understand and comment.

In this sample I have a class BankAccount. I will serialize the BankAccount object to XML with 2 properties and use XMLReader to get back what have been written to the XML file (in the sample the file name for XML file is XMLBank.xml).

For this sample I glue the WriteXML and ReadXML method with the BankAccount. The entire class as below: 

public class BankAccount

  {

    public String AccID { get; set; }

    public double Amount { get; set; }

 

    public void WriteXML()

    {

      XmlSerializer serializer;

      TextWriter writer = new StreamWriter("XMLBank.xml");

 

      BankAccount bc = new BankAccount();

      bc.AccID = "13-0001";

      bc.Amount = 1000000;

 

      serializer =  new XmlSerializer(typeof(BankAccount));

      serializer.Serialize(writer, bc);

      writer.Close();

    }

 

    public void ReadXML()

    {

      XmlReader reader = XmlReader.Create("XMLBank.xml");

 

      reader.Read();

      reader.ReadStartElement("BankAccount");

      reader.ReadStartElement("AccID");

      Console.WriteLine(reader.ReadString());

      reader.ReadToFollowing("Amount");

      Console.WriteLine(reader.ReadString());

    }

  }

Doing it this way then the application will not tie down to any database such as Oracle Database or MS SQL.  If you have better and easier link then do share with me.

The complete code is in http://skydrive.live.com. The sample file name is ConsoleObjtoXML.rar. My MSN ID is chanmmn@hotmail.com.


Resources:


A Beginner's Guide to the XML DOM


XML Technology Center

About October 2008

This page contains all entries posted to Ming Man Chan's Blog in October 2008. They are listed from oldest to newest.

September 2008 is the previous archive.

November 2008 is the next archive.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type and Oracle