Saturday, December 22, 2007

Joomla problem with incorrect SQL export

Today I had experienced a weird problem with my Joomla upload. After uploading to live server, my mod_smoothgallery from OsCandy was not displaying and StopPress Module that should be appear on top all other content was not displaying but was blocking all other so they can not be clicked. When I enter administration site, the menu was not displaying either. Because of that, I thought the problem was only effecting JavaScript related components and also related to files/folder permission mode. I tried to change mode the files and folders, but still there was no effect. And then I installed another instance of Joomla using Elefante Installer, an automated script installer provided by the hosting provider.

After installing fresh copy of Joomla, I check the administration menu bar, and there it was. And when I check the files permission are the same with the one I had. So, I tried to copy all the files to overwrite my site with no good result. Finally I found the problem was with the SQL export-import. I export SQL from my localhost development server by using HeidiSQL and apparently it gives incompatible format so when I import to the live server it was not importing properly. Thank goodness I was using Apace2Triad which comes with PhpMyAdmin so I just re-export from there and re-import from the live server's PhpMyAdmin. Voila! it worked perfectly again. So, the site can run smoothly from now.
Please visit the site at www.chinese-studies.org. We will updating more content in the future, so please visit often for you guys who interested in chinese cultures ;)

Saturday, November 24, 2007

Pivot Table with Multiply Key Columns in C#

I needed a pivot table to display a report to the user in my company, so I tried googling the best and practical way to do that. At first, I was interested in using MS Office components and just pass the data to the component and refresh the template so it will display the data I need. But, the thing is I will need the component also to be installed in the server, and this is not a really high priority apps to put the server in risk to not working for some time if there is anything wrong with the installation or the components it self. So, I decided using the data table manipulation and I found a good example on how to do that in weblogs of sql team here.

However, there is small modification I need to do since the function written there only accommodate single key column. After modified it, I was planning to put the update in comments of the page so I can contribute somehow. Unfortunately the comments is already closed, so I decided to put it here. Find it below. This pivot function is placed in a web service which is going to return a dataset containing the pivot table. After receiving it in the web app, I format the datagrid so it will display as the user need. Yay! Alhamdulillah. Hope it will be useful for other people who need it.



/// <summary>
/// Transform a table to a pivot table based on the given information.
/// </summary>
/// <param name="dataValues">The table which is going to be transformed to pivot table. The table should be sorted by the key colums, starting from most left part.</param>
/// <param name="keyColumn">Array of String which contains the columns in dataValues that is going to be used as a keyColumn for display</param>
/// <param name="pivotNameColumn">The Column name of the dataValues which is going to be displayed as pivot table's column</param>
/// <param name="pivotValueColumn">The Column name of the dataValues which is going to be used to fill the value for the pivot table's column</param>
/// <returns></returns>
public static DataTable Pivot( DataTable dataValues, string[] keyColumn, string pivotNameColumn, string pivotValueColumn)
{
try
{
DataTable tmp = new DataTable();
DataRow r;
string[] LastKey = new string[keyColumn.Length];
int i,keyColumnIndex, pValIndex, pNameIndex;
string s;
bool FirstRow = true;
bool keyChanged = false;

// Add non-pivot columns to the data table:
pValIndex = dataValues.Columns.IndexOf(pivotValueColumn);
pNameIndex = dataValues.Columns.IndexOf(pivotNameColumn);

for (i = 0; i <= dataValues.Columns.Count - 1; i++)
if (i != pValIndex && i != pNameIndex)
{
tmp.Columns.Add(dataValues.Columns[i].ColumnName.ToString(), dataValues.Columns[i].DataType);
}
r = tmp.NewRow();

// now, fill up the table with the data:
foreach (DataRow row in dataValues.Rows)
{
// see if we need to start a new row
keyColumnIndex = 0;
keyChanged = false;
if (!FirstRow)
{
while (!keyChanged && keyColumnIndex < keyColumn.Length)
{
if (row[keyColumn[keyColumnIndex]].ToString() != LastKey[keyColumnIndex])
{
keyChanged = true;
}
keyColumnIndex++;
}
}
else
{
for (keyColumnIndex = 0;keyColumnIndex<keyColumn.Length;keyColumnIndex++)
{
LastKey[keyColumnIndex] = row[keyColumn[keyColumnIndex]].ToString();
}
}

if (keyChanged || FirstRow)
{
// if this isn't the very first row, we need to add the last one to the table
if (!FirstRow)
{
tmp.Rows.Add(r);
}
r = tmp.NewRow();

// Add all non-pivot column values to the new row:
for (i = 0; i <= dataValues.Columns.Count - 3; i++)
{
r[i] = row[tmp.Columns[i].ColumnName];
}
FirstRow = false;

for (keyColumnIndex = 0;keyColumnIndex<keyColumn.Length;keyColumnIndex++)
{
LastKey[keyColumnIndex] = row[keyColumn[keyColumnIndex]].ToString();
}
}

// assign the pivot values to the proper column; add new columns if needed:
s = row[pNameIndex].ToString();
if (s.Length > 0)
{
if (!tmp.Columns.Contains(s) && s != null)
{
tmp.Columns.Add(s, dataValues.Columns[pValIndex].DataType);
}
r[s] = row[pValIndex];
}
}
// add that final row to the datatable:
tmp.Rows.Add(r);

// and that's it!
return tmp;
}
catch (Exception)
{
return null;
}
}

Monday, November 05, 2007

Flashing Windows Mobile 6 to my X01HT

Sometimes ago, I had my HTC unlocked, and it was already able to use other mobile operator connection, but I was still getting the locking screen when I inserted other SIM than Softbank. At first, I only research how to remove the annoying screen, but I found better thing, not only I can remove the annoying screen, I also should be able to upgrade to windows mobile 6, which is very cool. Thank you guys in XDA developers forum! Certainly I already put links to your pages/threads below.

I bought my X01HT on September 2006 so I do not have any problem with ROM and radio version. I will describe below how I made my Japanese Softbank X01HT to an English Unlocked Smartphone with Japanese input and proprietary MMS capability (MMS not fully worked, I will update again if I already solve the problem).
  1. Unlock the operator restriction so it can use all GSM SIM all over the world using Hermes unlocker by POF. Follow this link to find downloadable zip file, download, extract and follow the instructions found in the text file
  2. Flash WM6 mobile ROM cooked wonderfully by Schaps to have an English OS in your smartphone. Download the executable file and run it with active sync active. If you can not download from the link, try this page. Congratulations! Now you already have an unlocked english version windows mobile smartphone. Let's continue.
  3. Time to make your phone displays Japanese, download this Zip file, extract and copy the cab file to your device and run inside it.
  4. Download this MMS Lite, extract and run the CAB file in your device and enjoy Softbank's proprietary MMS.
  5. For the input, eventhough it is said that you can have other type of input, I prefer IME input which it had before. You can download from here, copy the cab to the phone and run it.
The phone is ready to go! You now have an English, Unlocked, Japanese capable Smartphone, with Softbank's proprietary MMS enabled. Congratulations!

Make sure you follow the instructions for each step in each manual found carefully. But, if not you can always start again from the beginning. Don't worry about breaking your phone since step 1 and 2 which is the most dangerous are already equipped with Hard-SPL/SSPL flashing which is said can protect from bricking the phone. That is my opinion, but for more cautious guy, you may want to check the XDA forum first. Furthermore, my X01HT is before Dec 2006 version, so I do not have too much obstacle.


Next step is installing softwares for my phone so I can be more productive and have fun with it. My choice of free powerful softwares to be first installed are :
  1. Mobipocket to read e-books - you can also easily make/convert ebooks from other formats using Mobipocket Creator as simple as drag and drop and synchronize with your device seamlessly.
  2. MS Reader - for ebook with lit format
  3. Pocket Islam - complete package so I can hear Quran while reading the meaning. The sound is linked with the text, it will highlight the ayat that is being played in reciter sound. Cool!
  4. TCPMP with divx, flv codecs - complete multimedia solution. You can play many format of videos and music

Credits: