March 29 2014

PHP how to insert Chinese character into MySQL

Tagged Under : ,

php
The way to insert Chinese character into MySQL table. You need set the table structure charset to utf8.
CREATE TABLE IF NOT EXISTS `contents` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
After that, add the following code as below:
mysql_connect(HOST, USER, PASSWORD);
mysql_select_db(DBNAME);
mysql_query("SET NAMES 'utf8'");
mysql_query("SET CHARACTER_SET_CLIENT=utf8");
mysql_query("SET CHARACTER_SET_RESULTS=utf8");

March 09 2014

ASP.net display MSSQL DateTime on razor.

Tagged Under : ,

asp.net
MSSQL store DateTime format is standard. But sometimes we need change the format to display it to user, let them more easy read and understand which Datetime format was set in our Application.

If use ASP.net retrieve the MSSQL DateTime Data to you application, it will display like below format.
asp.net

But, when validate the DateTime with ASP.net it will return an error.
asp.net

Because the DateTime format set in ASP.net was “06-03-2014 12:00:00 AM”. But now we just need to display Date only not need time.

March 04 2014

ASP.net summary of return Action Result type

Tagged Under :

asp.net
There are different type of results that are available in ASP.net MVC. When create new controller, they will come with actions by default. The Empty controller includes an Index action with a return value of type ActionResult. ActionResul class is the base class for all action results.

There are different ActionResult types explained below.