Tuesday, November 18, 2014

Update your Window phone (Samsung Focus SGH-i197) to from Window 7.5 to 7.8 (7.10.8862.144)

Update your Window phone (Samsung Focus SGH-i197) to from Window 7.5 to 7.8 (7.10.8862.144)

It works for me for my Samsung Focus SGH-i197. Be patient it may take around 45 min. it will restart your phone multiple times, update will start from 7.10.8112.7 and go till 7.10.8862.144 final version. you installation only complete when "Congratulation! you'r done!" message box pops up. then you can close the application.

Download below two files from below link and follow the given instruction

Sunday, November 16, 2014

Update your Samsung SGH-i197 window phone from 7.10.7720 to 7.10.8101.79 without Zune forcefully

Below steps works for me on my Window Phone (Samsung SGH-i197) having OS 7.10.7720

Count Display Language in your phone, Go to Setting >> Language

Download files based on language in your phone.
Here are the individual languages that you need to download to the same directory as the OS install files from above English (US) language pack Chinese (traditional), Chinese (simplified), GermanCzechFrenchEnglish – UK, Spanish, Danish, Greek, Finnish, Hungarian, Italian, Japanese, Korean, Dutch, Norwegian, Polish,Portuguese – (Brazil), Russian, Swedish, Portuguese – (Portugal)
If you need all 22 in one shot, just download this file. Do NOT install extra languages.
Download the ZIP file here and keep in in your local PC drive (i.e. C:\Phone)

Download and install the appropriate file based on your PC OS version
Follow below steps
1.    Make sure your phone is charged to at least 50%
2.    Plug your phone via USB into your computer and close Zune Desktop (yes, close it)
3.    On your computer, navigate to where you extracted the OS update: Cab Sender --> Tools --> x86/x64(Choose one based off your system architecture)
4.    Run UpdateWP.exe (Note: you should see a DOS screen flash and disappear)
5.    Back out to your main directory and run WP7 Update Cab Sender.bat
6.    Choose 'B' (This will back up your device to Zune, then install the updates)

Reference Site: See below site for more details and troubleshoots

To update Window 7.5 to 7.8 (7.10.8862.144) please see below link

Thanks for

Saturday, November 15, 2014

Multiple ways to Export data into Excel using .net and SQL server

There are many ways to export data into excel, need to analyze following requirement before choosing any methods like:
  • Volume of data,
  • Dynamic behavior,
  • Schedule export or Manual export
  • Performance & Scalability
  • Security
  • Operating system, (32 or 64 bit etc.)

Based on above requirement you can decide best approach for export. I would suggest create proof of concept and do your entire requirement testing carefully before taking final decision.

1. Export data using Microsoft Office.Interop Library

Microsoft .NET provides Interop library to create excel object and export data table or data grid view into excel sheet, this object is very useful when you require designing fancy excel sheet using all excel features; like: cell design, formula, header & footer design etc.

                    - Complete programming support to Excel via C#
                    - Integrated with to Visual studio

                    -You must have Excel installed on your system for this code to run properly.
                    -To use COM interop, you must have administrator or Power User security permissions
                    -It is little slow to handle heavy data load and not enough to load large size of
2. Export data using OpenXML SDK 2.0

Open XML SDK 2.0 lets developers be more productive by providing design-time capabilities such as IntelliSense support and a type-safe development experience. You can download from Download SDK.

                 -Doesn't require Microsoft Office installed
                 -Made by Microsoft , decent MSDN documentation
                 -Just one .Net dll require to use in project
                 -SDK comes with many tools like diff, validator, etc.            
                 -The SDK is stable and it is supported by Microsoft.
                 -LINQ can be used to navigate data of excel file.
                 -It performs operations with just a few lines of code.

                 -It supports only the documents created in Office 2007 or later (i.e. xlsx, docs etc)
                 -It cannot render Office functions. You can't do Excel calculations rendering on                       the server-side. 

3. Export data in CSV file using StreamWtiter

If you requirement to just export the data into plain excel file, single sheet, no column formatting needed then you should go with CSV file creation instead of Excel. This solution works very well with large size of data. Tested with 1 million rows with file size around 2 GB.

                -No Extra DLL require
                -Faster than creating excel file
                -Can handle large data size

                -Creates single excel sheet only
                -No formatting support
                -Need to remove special char like: “’,” (Comma) 

Public string RemoveInvalidChar(string input)
  List<string> invalidItems = new List<string>()
      ",", "/r", System.Environment.NewLine

  foreach (string invalidItem in invalidItems)
    input = input.Replace(invalidItem, "");
   return input;

private void btnExport_Click(object sender, EventArgs e)
    int cols;
    //open file
    StreamWriter wr = new System.IO.StreamWriter(@"C:\PerformanceTest.csv", false, Encoding.UTF8);
    //Create datatable having huge rows and columns
    DataTable dt = GetDataTable();
    //determine the number of columns and write columns to file
    cols = dt.Columns.Count;
    for (int i = 0; i < cols; i++)
        wr.Write(dt.Columns[i].ToString().ToUpper() + ",");
    //write rows to excel file
    for (int i = 0; i < (dt.Rows.Count); i++)
      for (int j = 0; j < cols; j++)
        if (dt.Rows[i][j] != null)
           wr.Write(RemoveInvalidChar(dt.Rows[i][j].ToString()) + ",");
      //close file

4. Export data using OLEDB provider

The basic format for the Microsoft.Jet.OLEDB.4.0 provider is: [32-bit SQL Server for Excel 2003]
INSERT INTO OPENROWSET ('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=c:\contact.xls;',
'SELECT * FROM [Sheet1$]')
SELECT TOP 5 doc_id,doc_name FROM document
  'Excel 8.0;Database=C:\excel-sql-server.xls', [Sheet1$])
  'Data Source=C:\excel-sql-server.xls;Extended Properties=Excel 8.0')...[Sheet1$]
The basic format for the Microsoft.ACE.OLEDB.12.0 provider is:[64-bit SQL Server for any Excel files or 32-bit SQL Server for Excel 2007]
INSERT INTO OPENROWSET ('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;Database=c:\contact.xls;',
'SELECT * FROM [Sheet1$]')
SELECT TOP 5 doc_id,doc_name FROM document
  'Excel 12.0;Database=C:\excel-sql-server.xlsx', [Sheet1$])
  'Data Source=C:\excel-sql-server.xlsx;Extended Properties=Excel 12.0')...[Sheet1$]

   -Microsoft.Jet.OLEDB.4.0 and Microsoft.ACE.OLEDB.12.0 has to be registered.
   -Microsoft.ACE.OLEDB.12.0 provider work with SQL Server x64 for any Excel             version files.
How to registered OLEDB
#1: Manually register those DLLs.
  1. Go to Start->Run and type cmd
  2. this starts the Command Prompt
  3. (also available from Start->Programs->Accessories->Command Prompt)
  4. Type cd .. and press return
  5. Type cd .. and press return again (keep doing this until the prompt shows :\> )
  6. Now you need to go to a special folder which might be c:\windows\system32 or it might be c:\winnt\system32 or it might be c:\windows\sysWOW64

        try typing each of these e.g.
             cd c:\windows\sysWOW64
             (if it says The system cannot find the path specified, try the next one)
             cd c:\windows\system32
             cd c:\winnt\system32  
        When one of those doesn't cause an error, stop, you've found the correct                     folder
    7. Now you need to register the OLE DB 4.0 DLLs by typing these commands and           pressing return after each
  • regsvr32 Msjetoledb40.dll
  • regsvr32 Msjet40.dll
  • regsvr32 Mswstr10.dll
  • regsvr32 Msjter40.dll
  • regsvr32 Msjint40.dll

#2:  Open the project in Visual Studio then:
  • From the solution explorer right-click your project then click Properties
  • Click the Build tab
  • Change Platform target from: Any CPU to x86
  • Re-build your solution