Posts

C# - Entity Framework - GROUP BY/ORDER BY/SELECT WHERE IN

var _inner_query = this.g_db_entity.ACTIVITIES                 .Where(w => (DateTime.Today <= w.ACTIVITY_DATE_TO))                 .GroupBy(g => g.ACTIVITY_DATE_FROM)                 .OrderBy(o => o.Key)                 .Select(s => s.Key)                 .Skip((pageNo - 1) * this.g_page_size)                 .Take(this.g_page_size); LIST<ACTIVITIES> _entity_activity = this.g_db_entity.ACTIVITIES                  .Where(m => _inner_q...

C# - Binary PDF File on Web Broswer via Binary Stream

Your binary PDF File was saved in MSSQL2008 in image data type. Byte[] _binary_document;// you get your binary data from database and assign to this parameter. //Result of binary stream Response.ContentType = "Application/pdf"; Response.AppendHeader("Content-Length", _binary_document.Length.ToString()); Response.BinaryWrite(_binary_document);

C# - Image to Byte Array and vise versa

System.Drawing.Image img = System.Drawing.Image . FromFile ( @"C:\Lenna.jpg" ); byte[] _byte_array = imageToByteArray(img, "jpg");     ------------------------------------------------------   public byte [] imageToByteArray(System.Drawing.Image imageIn , String imageFileType ) {    MemoryStream ms = new MemoryStream();    switch(imageFileType.ToLower()) {   case "gif": imageIn.Save(ms,System.Drawing.Imaging.ImageFormat.Gif); break; case "jpg": case "jpeg":   imageIn . Save ( ms , System . Drawing . Imaging . ImageFormat . Jpeg ); break; }   return ms.ToArray(); }   ------------------------------------------------------   public Image byteArrayToImage( byte [] byteArrayIn) { MemoryStream ms = new MemoryStream(byteArrayIn); Image returnImage = Image.FromStream(ms); return returnImage; }     web reference: http://www.codep...

JAVA - Check the value exists in an array

Check if a value exists in an array:   Arrays . asList ( someArray ). contains ( value );     ** It's not workd for array of integer, but array of string is ok. 

PHP - if statement (shorthand)

<?php          $input_type = "daily";          echo ($input_type == "daily"? "yes" : "no") ?>

PHP - Fatal error: Call to undefined function curl_init()

Fatal error: Call to undefined function curl_init() Resolve for Windows: 1. Open "php.ini" (AppServ Apache Server -> Start Menu -> All Programs -> AppServ -> Configuration Server -> PHP Edit the php.ini Configuration File) 2. Find the text ";extension=php_curl.dll" 3. Remove "semi-colon" at the first of the text, the text will be "extension=php_curl.dll" 4. Save the file and restart Apache Server ------------------------------------------------------------ If the error is not solve, please try this solution  (Reference to Windows7). 1. Right click on "My Computer" -> Properties -> Advanced system settings 2. Select "Advanced Tab" -> Environment Variables -> System Variables 3. Choose "Variable Path" -> Click Edit 4. Append path of your PHP folder in the current string example. "C:\AppServ\php5;" 5. Click "OK" and restart your computer It...

PHP - Displaying MySQL Column Names and Values via PHP

$result = mysql_query($sql); if ($result) {         $total_row = mysql_num_rows($result); } if ($total_row > 0) {         while ($tableRow = mysql_fetch_assoc($result)) {                $result_body.= "<item>";                foreach ($tableRow as $column => $value) {                     $result_body.= "<{$column}><![CDATA[{$value}]]></{$column}>";                }                $result_body.= "</item>";         } }