วันพุธที่ 26 กันยายน พ.ศ. 2555

Build Class in Visual Studio and copy to other destination.

Useful for who need auto copy dll so we don't need to manual it.

Ex.
xcopy /y $(ProjectDir)$(OutDir)$(TargetFileName) "C:\Users\pakoros\Documents\Visual Studio 2010\Projects\E-Questionare\CommonLib\CommonDLLs"

This mean after build it will copy to my destination in Visual studio project.
This can setting in
Project Properties > Build Events (Right click on project and setting it.)
in
Post-build event command line:

วันอังคารที่ 4 กันยายน พ.ศ. 2555

PHP include UTF8 have strange line or space.

Because UTF8 hast 2 type this explain in

http://www.w3.org/International/questions/qa-utf8-bom.en.php

This explain about UTF8 BOM and Remove BOM

For Visual Studio.NET Use
UTF8 with signature for BOM and
UTF8 without signature for remove BOM

To do this you must use "File > Advanced save options..."

วันอาทิตย์ที่ 2 กันยายน พ.ศ. 2555

php 5.2, 5.3, 5.4 connected mssql with sqlsrv

1. Download SQLSRV30.EXE at

http://www.microsoft.com/en-us/download/details.aspx?id=20098
For use with PHP 5.2 you need SQLSRV20.EXE instead for more details see
http://www.php.net/manual/en/sqlsrv.installation.php

2. Read instruction to install or run download file point location to php extension folder.
3. Install it will get file dll and manual in your extension folder.
4. add extension call in your php.ini file (this ex. use for PHP 5.4 thread safe version)
extension=php_sqlsrv_54_ts.dll

5. Go for Test Code.
/* Specify the server and connection string attributes. */
$serverName = "(localhost)\SQLExpress";

/* Get UID and PWD from application-specific files.  */
$uid = file_get_contents("C:\AppData\uid.txt");
$pwd = file_get_contents("C:\AppData\pwd.txt");
$connectionInfo = array( "UID"=>$uid,
                         "PWD"=>$pwd,
                         "Database"=>"your_db_name");

/* Connect using SQL Server Authentication. */
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn === false )
{
     echo "Unable to connect.</br>";
     die( print_r( sqlsrv_errors(), true));
}

/* Query SQL Server for the login of the user accessing the
database. */
$tsql = "SELECT CONVERT(varchar(32), SUSER_SNAME())";
$stmt = sqlsrv_query( $conn, $tsql);
if( $stmt === false )
{
     echo "Error in executing query.</br>";
     die( print_r( sqlsrv_errors(), true));
}

/* Retrieve and display the results of the query. */
$row = sqlsrv_fetch_array($stmt);
echo "User login: ".$row[0]."</br>";

/* Free statement and connection resources. */
sqlsrv_free_stmt( $stmt);
sqlsrv_close( $conn);

MS SQL 2012 "Saving Changes is not permitted"

After Create New table and try to add Primary Key later my mssql server 2012 Express not allow me to that but tell me to drop and recreate table instead.

This is bad because long time ago I do this with no problem.
To make it work like before go to
Tools > Options > Designers > Table and Database Designers
and unchecked "Prevent saving changes that require table re-creation" 
Turnoff this option will take the risks.
See more information at http://support.microsoft.com/kb/956176

But I don't need to track my tables because i work on the fly and often set primary key later after create table.

Windows 7 IIS With FastCgi

I try to add Module PHP with fastcgi today but cannot find it in Module list.
For make IIS to support FastCgi must install CGI support in
Application Development Features

 And you will have IIS7 in IIS Panel (If don't see Close IIS and open it again).