Experience in C++, C#, Java and Process : Living in Montreal

* What is my technical experience as a software developer

* What I have learned in the software business

* Where I am heading to in my career

* How to process in a project

Friday, March 11, 2005

ADO.NET Datagrid database caching in VS.NET

// Add a new record to the database directlly
// It is very slow since it is operating to the db without caching
//
public void AddLog(string info)
{
objDatasetLog.LogTable.AddLogTableRow( DateTime.Now, 0, "User", info);
}

//
// Better approach:
//
// Create a cache record, then merge to the real database laterly
//
public void AddLog(string info)
{
// Create a new dataset to hold the records returned from the call to FillDataSet.
// A temporary dataset is used because filling the existing dataset would
// require the databindings to be rebound.
PDFAuto.DatasetLog objDataSetTemp;
objDataSetTemp = new PDFAuto.DatasetLog();
try
{
// Attempt to fill the temporary dataset.

objDataSetTemp.LogTable.AddLogTableRow( DateTime.Now, 0, "User", info);
}
catch (System.Exception eFillDataSet)
{
// Add your error handling code here.
throw eFillDataSet;
}
try
{
grdLogTable.DataSource = null;
// Empty the old records from the dataset.
objDatasetLog.Clear();
// Merge the records into the main dataset.
objDatasetLog.Merge(objDataSetTemp);
grdLogTable.SetDataBinding(objDatasetLog, "LogTable");
}
catch (System.Exception eLoadMerge)
{
// Add your error handling code here.
throw eLoadMerge;
}

}

Thursday, March 03, 2005

Set width and precision in iostream of STD

1. Call precision and width close to cout;
2. fixed to enforce to show a float as 23.45 format

int nLine = 1; for ( int i = 0; i < 100; i += 5)
{
cout.precision( 2); cout.width( 6);
cout << fixed << inch2cm( i) << " ";
if ( nLine % 10 == 0)
{ cout << endl; }
nLine++;
}