USE Northwind;
GO
IF OBJECT_ID ('TableUpdateTrigger','TR') IS NOT NULL
DROP TRIGGER TableUpdateTrigger;
GO
CREATE TRIGGER TableUpdateTrigger
ON Categories
AFTER INSERT, UPDATE, DELETE
AS
IF NOT EXISTS (SELECT * FROM zzzTableUpdates WHERE TableName='Categories')
INSERT INTO zzzTableUpdates (TableName, LastUpdate) Values ('Categories', GETDATE())
ELSE
UPDATE zzzTableUpdates SET LastUpdate=GETDATE() WHERE TableName='Categories'
GO
Friday, February 26, 2010
SQL Server Trigger to tracking last data updates
Monday, February 15, 2010
Tuesday, February 9, 2010
.NET Windows Form - Display the standard DataLink property dialog box as child window of current form
Want to shared some of my experience to use DataLink form to edit database connection string in windows form application.
The hardest part is to set DataLink form as child window of current form. But fortunately, I find a way to set HWnd property to get it solved.
Here is the code:
1: Public Function GetConnection() As String2: Dim dc As MSDASC.DataLinks = New MSDASC.DataLinksClass()3: Dim oConnection As Object = GetFakeOledbConnectionString(existingConnectionString)4: dc.hWnd = Me.Handle '//Set parent window to current form5: If dc.PromptEdit(oConnection) Then6: Return CType(oConnection, ADODB._Connection).ConnectionString7: Else8: Return Nothing9: End If10: End Function11:12: Private Function GetFakeOledbConnectionString(ByVal str As String) As Object13: If String.IsNullOrEmpty(str) Then14: str = "Integrated Security=SSPI; Persist Security Info=True;Password=1;"15: End If16: If Not str.StartsWith("Provider", StringComparison.OrdinalIgnoreCase) Then17: str = "Provider=SQLOLEDB;" + str18: str = str.Replace("Integrated Security=True", "Integrated Security=SSPI")19: If Not str.ToLower().Contains("Persist Security Info".ToLower()) Then20: str = str.TrimEnd(" ").TrimEnd(";") + "; Persist Security Info=True;"21: End If22: End If23: Dim position As Integer = str.IndexOf("AttachDBFile", StringComparison.OrdinalIgnoreCase)24: If position > 0 Then25: str.Replace("AttachDbFilename=;", "")26: End If27: Dim adoConnection As ADODB._Connection = New ADODB.ConnectionClass()28: adoConnection.ConnectionString = str29: Return adoConnectionEnd30: Function
Tuesday, February 2, 2010
Silverlight: how to update UI before time comsumming process
I was trying to make my Silverlight application to update UI before start a time consuming process. For some reason, I can use put that process in new thread. So I have to implement some technique as following:
this.UpdateLayout(); //I want UI update before start that process
new Thread(() =>
{
Thread.Sleep(100); //Update UI first
this.Dispatcher.BeginInvoke(() =>
{
//Long time process, which stop UI updates
});
}).Start();