Saturday, July 23, 2005
While I'm trying to do this for one access database, it gives me 18 records!!
SELECT TOP 10 Right([FromYear],4) AS FromYear, Right([ToYear],4) AS ToYear, 'spm' + mid([Reference No],1,4) + '-' + mid([Reference No],5,2) + '-' + mid([Reference No],7,2) + '-' + mid([Reference No],9,3) + '.jpg' AS PicRefNo, [Reference No] AS AccessionNo, [Item] FROM tblStamps WHERE 1=1 AND [Description] LIKE '%king%' AND [Reference No] NOT IN (SELECT TOP 10 [Reference No] FROM tblStamps WHERE 1=1 AND [Description] LIKE '%king%' ORDER BY FromYear, ToYear ) ORDER BY FromYear, ToYear
I believe it is the ORDER BY which confused up the TOP, and both of them can't be used together (not compatible).
Friday, July 22, 2005
Subsequently, I've consulted Dr.Google and he refer me to Mr.MSDN:
Quote from the address:
Using the Office XP PIAs and the Office 2003 PIAs
PIAs are version specific, so you should use the same version of the PIAs as the application version. For example, if you want to migrate your Microsoft Office XP managed code solution to Microsoft Office 2003, you should recompile the Office XP managed code solution with Office 2003 PIAs.
You should also have two different setup packages—one for Office XP and another for Office 2003—if you intend for the same solution to work in both Office XP and Office 2003. Deployment of PIAs for Office XP is very different from that for Office 2003. For further information about these differences, see the ReadMe file included in the Office XP PIAs download.
Wonder if anyone have similiar experience with building apps that writes to office documents?
Just wonder if there's Office 2000 interop or shall I conclude that working w/o interop will yield the best compability?
However, these has to be used carefully, as the garbage collection won't automatically clear and release the memory used by the COM objects. This problem arise when my colleague asking me about how to solve it, as she observed that there's many EXCEL.EXE running in the taskbar after she run her program which creates excel spreadsheet. While I've read about it, but have never get a chance to use it, thanks again to Dr.Google which always faithfully give me the answers within seconds.
Releasing of unmanaged code (COM) from managed code (.NET) calls:
Below are quoted from the site for easy reference:
To make sure that the Office application quits, make sure that your automation code meets the following criteria:
• Declare each object as a new variable. For example, change the following line of code
oBook = oExcel.Workbooks.Add()
to the following:
dim oBooks as Excel.Workbooks
oBooks = oExcel.Workbooks
oBook = oBooks.Add()
• Use System.Runtime.InteropServices.Marshal.ReleaseComObject when you have finished using an object. This decrements the reference count of the RCW.
• To release the reference to the variable, set the variable equal to Nothing or Null.
• Use the Quit method of the Office application object to tell the server to shut down.
Sarissa to the Rescue
I've been cracking my head for 2 days to came up with a XML parse with regular expression. Which I've came up with it, but it is limited and have rooms to improve.
Wednesday, July 20, 2005
4GuysFromRolla - Regular Expressions
Greg Reinacker's Weblog
Nested Constructs in Regular Expressions (using .NET)
Using a Regular Expression to Match HTML
Regular Expression Library Builder
Along the way, I've found some cool tools for regular expression:
For references on regular expression:
Tuesday, July 19, 2005
Cross page posting will not work for DropDownList and further more as you investigate on, you'll discover that the cross post back actually process the previous page, which is not desired.
Tired of writing XML Document and tags? and even more tired when you have to code exactly the reverse thing when reading back from XML document?
The solution is to make use of the XML Serialization in .NET!
This example shall give you an overall idea of the XML serialization function of .NET.
--> No more codes for XML Writing
--> No more codes for XML
--> 1000% higher productivity in writing codes
The codes sample is a prototype example for my company, which will be used as a file format eventually for data exchange.
Public Class PSF_XMLSerializer_PrototypeForm
Private Sub PSF_XMLSerializer_PrototypeForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim newPSF As New PortStatusFile
newPSF.FileVersion = "123"
newPSF.RevisionDate = "111"
newPSF.TS.Vessel_Code = "ABC"
newPSF.TS.Vessel_Oper = "XCL"
Dim xmlsel As New XmlSerializer(GetType(PortStatusFile))
Dim xmlWriter As New System.IO.StreamWriter("C:\test.txt")
Dim xmlReader As New System.IO.StreamReader("C:\test.txt")
Dim anotherPSF As PortStatusFile = CType(xmlsel.Deserialize(xmlReader), PortStatusFile)
anotherPSF.RevisionDate = "9999"
anotherPSF.TS.Line = "SEA"
Dim xmlW2 As New System.IO.StreamWriter("C:\test2.txt")
<XmlRootAttribute("PSF", Namespace:="Seacon.eBiz", IsNullable:=False)> _
Public Class PortStatusFile
Public FileVersion As String
Public RevisionDate As String
Public SID As String
Private DateTimeFormat As String
Public TS As TerminalDetails
Public CS As CargoDetails
Public Sub New()
Me.TS = New TerminalDetails
Me.CS = New CargoDetails
<XmlRoot("TDR", IsNullable:=False)> _
Public Class TerminalDetails
Public Vessel_Code As String
Public Vessel_Name As String
Public Vessel_Oper As String
Public Voyage As String
Public Leg As String
Public Line As String
Public Port_Code As String
<XmlRoot("SM", IsNullable:=False)> _
Public Class CargoDetails
Public SMD As ArrayList
Public Sub New()
Me.SMD = New ArrayList
<XmlRoot("SMD", IsNullable:=False)> _
Public Class SMDetails
Public Cntr_Num As String
Public Sub New()
Public Sub New(ByVal cntrNum As String)
Me.Cntr_Num = cntrNum
If you wanted to add stylesheet to your serialized object, check this out: