Check out this unicode regex editor from RadSoftware. Came across this in Microsoft TechNet April 2009.
Alternatively, this is the one I personally prefer -> Expresso Regex editor (version 3.0)
Monday, March 30, 2009
DataView sorting issue on new record inserted
1. Scenario:
I was working on a project of feeding live data to a datagrid view (dgv) with just-in-time data loading. The dgv is populated from a datatable.DefaultView and should sort by the latest updates.
The screen data is cached and loaded from the underlying datatable when the user scrolls down the dgv. The gridview doesn't have to load 500,000 records when it initialise. Thus, greatly reducing the memory footprint and waiting time.
MSDN: Just-In-Time Data Loading in DataGridView Control
The gridview refreshes itself when new data arrives. The user sees the latest record appearing on top of the gridview.
## Code snippet (Starts)-----------------------------------------------------
DataView _latestPriceView = _dtPrices.DefaultView;
_latestPriceView.Sort = "PriceUID DESC"
// obtain the latest price unique-id and perform further processing
uid = (_latestPriceView.Table.Rows(0).Item(0))
## Code snippet (Ends)-----------------------------------------------------
2. What is the problem:
The issue happens new price arrives. It has been added to the bottom of dtPrices datatable. The dataview that build from the datatable should have sorted the latest record to the top. However, it hasn't and the row is at the bottom of the dataview rows.
What is going on here?
3. Mitigation:
The reason is dataTable is not sorted but DataView is. Finding the top element from dataview gives you the latest uid. Performing that on the unsorted datatable give you latest uid since it was retreive from data source. The latest record is at the bottom of the datatable.
Do not use theDataView.Table. Rows[0]. Reference the dataview item directly without using the table properties.
e.g.
DataView[i].Item[0]
## Code snippet (Starts)-----------------------------------------------------
DataView _latestPriceView = _dtPrices.DefaultView;
_latestPriceView.Sort = "[PriceUID] DESC"
// obtain the latest price unique-id (normally the first row from the dataview rows)
// Perform further processing ...
int32 uid = _latestPriceView(0).Item(0) // direct referencing to the view item does the trick.
If you try to use
int32 uid2 = _lastestPriceView.Table.Rows[0].Item[0] // This correspong to the datatable first row [_dtPrices(0)] rather than the last update which is inserted at the bottom of the datatable -> _dtPrices.Rows[_dtPrices.Rows.Count-1].Item[0]
## Code snippet (Ends)-----------------------------------------------------
I was working on a project of feeding live data to a datagrid view (dgv) with just-in-time data loading. The dgv is populated from a datatable.DefaultView and should sort by the latest updates.
The screen data is cached and loaded from the underlying datatable when the user scrolls down the dgv. The gridview doesn't have to load 500,000 records when it initialise. Thus, greatly reducing the memory footprint and waiting time.
MSDN: Just-In-Time Data Loading in DataGridView Control
The gridview refreshes itself when new data arrives. The user sees the latest record appearing on top of the gridview.
## Code snippet (Starts)-----------------------------------------------------
DataView _latestPriceView = _dtPrices.DefaultView;
_latestPriceView.Sort = "PriceUID DESC"
// obtain the latest price unique-id and perform further processing
uid = (_latestPriceView.Table.Rows(0).Item(0))
## Code snippet (Ends)-----------------------------------------------------
2. What is the problem:
The issue happens new price arrives. It has been added to the bottom of dtPrices datatable. The dataview that build from the datatable should have sorted the latest record to the top. However, it hasn't and the row is at the bottom of the dataview rows.
What is going on here?
3. Mitigation:
The reason is dataTable is not sorted but DataView is. Finding the top element from dataview gives you the latest uid. Performing that on the unsorted datatable give you latest uid since it was retreive from data source. The latest record is at the bottom of the datatable.
Do not use the
e.g.
## Code snippet (Starts)-----------------------------------------------------
DataView _latestPriceView = _dtPrices.DefaultView;
_latestPriceView.Sort = "[PriceUID] DESC"
// obtain the latest price unique-id (normally the first row from the dataview rows)
// Perform further processing ...
int32 uid = _latestPriceView(0).Item(0) // direct referencing to the view item does the trick.
If you try to use
int32 uid2 = _lastestPriceView.Table.Rows[0].Item[0] // This correspong to the datatable first row [_dtPrices(0)] rather than the last update which is inserted at the bottom of the datatable -> _dtPrices.Rows[_dtPrices.Rows.Count-1].Item[0]
## Code snippet (Ends)-----------------------------------------------------
Sunday, March 01, 2009
TRAC Cheat sheet
Create new project
Add user permission
- >trac-admin "C:\Trac\
" initenv - mysql connection string - mysql://root:myroot@
:3306/
Add user permission
- >trac-admin "c:\trac\
" permission add TRAC_ADMIN
Tuesday, February 24, 2009
Teamviewer - Free Remote Desktop apps
Cost: Free for non-commercial use.
For more information, go to TeamViewer website.
Scenario:
Bob tries to remotely view/control Susan's machine for virus troubleshooting.
What to do?
For Susan
- Download the TeamViewerQS and run it (Click on the link to download).
- Tell Bob the session id and password (depicted as the screen below).

- Download TeamViewer (full version) and run it.
- Connect using the session id and password provided by Susan.
Wednesday, February 18, 2009
C# How to parse date string into UK date format
DateTime ukdatetime = DateTime.Parse(usdatetime, System.Globalization.CultureInfo.CreateSpecificCulture("en-GB"));
Oracle PL/SQL SubQuery example
The following subquery uses EXISTS method to check whether the employee work in UK site. The crucial part of the query is the use of the usr.idemployee (main query) to filter the data in the subquery.
The subquery could be selecting from any tables but the query result is appended to the main query. The subquery result doesn't have to exist in any table.
select usr.iduser, usr.name,
DECODE ((SELECT 1
FROM DUAL
WHERE EXISTS (
SELECT dummy
FROM empworkplace wrk
WHERE usr.idemployee = wrk.idemployee
AND wrk.sitekey = 'UK'),
NULL, 0,
1
) AS fromUKSite,
from users usr.
The subquery could be selecting from any tables but the query result is appended to the main query. The subquery result doesn't have to exist in any table.
select usr.iduser, usr.name,
DECODE ((SELECT 1
FROM DUAL
WHERE EXISTS (
SELECT dummy
FROM empworkplace wrk
WHERE usr.idemployee = wrk.idemployee
AND wrk.sitekey = 'UK'),
NULL, 0,
1
) AS fromUKSite,
from users usr.
Subscribe to:
Posts (Atom)
