Generic BindingList in the .NET Framework 2.0

by Damiaan Peeters 7. December 2007 17:10

Learn about the generic BindingList and how to extend this generic collection type to add sorting and searching functionality.

Behind the Scenes: Improvements to Windows Forms Data Binding in the .NET Framework 2.0, Part 2

Windows Applications (How Do I in C#)

by Damiaan Peeters 6. December 2007 17:04

Today I found the  How Do I in C# series on MSDN.  The How Do I in series are a great way to get started with task-based topics for any C# programmer and application developer.

At this moment the Windows Applications (How Do I in C#)  page. This page links to help on widely used Windows applications tasks.

Windows Applications (How Do I in C#)

Blocking a IP address in Windows Server 2003

by Damiaan Peeters 5. December 2007 17:31

If you want to block a ip address in windows Server 2003, you can do this fairly easy by setting an inbound filter for that particular IP address.

Go to the

Administering Routing and Remote Access Service

choose there the  - IP filtering - General - the network connection - properties - inbound filter.

DDL Triggers

by Damiaan Peeters 4. December 2007 14:11

DDL stands for Data definition language.  Nothing new until now, you might know DDL as the alter, create and drop statements from SQL.

However, in Microsoft SQL Server 2005 it is possible to add triggers for these statements. 

These kind of triggers allow you to audit these potentially dangerous statements:

CREATE TRIGGER safety
ON DATABASE
FOR CREATE_TABLE, DROP_TABLE, ALTER_TABLE
AS
   PRINT 'You must disable Trigger "safety" to drop, create or alter tables!'
   ROLLBACK ;


DDL triggers fire only in response to DDL events specified by Transact-SQL DDL syntax. System stored procedures that perform DDL-like operations are not supported.

To see a list of the triggers created (in the system catalog), you can use this statement

SELECT name,te.type_desc,te.type
FROM sys.triggers t
JOIN sys.trigger_events te on t.object_id = te.object_id
WHERE t.parent_class=0
AND name IN('ddlTestEvents1','ddlTestEvents2')
ORDER BY name,te.type_desc

Where ddlTestEvents1 and ddlTestEvents2 are of course the names of the events.

If you need to create for the 3 statements the same trigger, you can use

FOR DDL_TABLE_EVENTS

instead of all the individual events.  You will observe the same effect in the triggers catalog.

Tags: , ,

SQL

Strange Microsoft Access Error on ADP project (Sql Server 2005 Extended Properties)

by Damiaan Peeters 2. December 2007 23:51

Today I got a very strange error on my Microsoft Access ADP Project.

image

Microsoft Office Access can't find the object 'SELECT *, sql_variant_property(value, 'basetype') AS type FROM ::fn_litextendedproperty(N'MS_DisplayViewsOnSharePointSite', N'user', N'dbo', N'table', N'TableName', NULL, NULL)'.

To be honest, I had no idea what this meant.  Neither the explanation followed by this error.
After thinking a little while, I found the solution.

Earlier today I tried to add a database schema.  And deleted it afterwards. 

If you look at the tables changed by the database schema, and the tables which where not involved, the only difference are the Extended Properties on the tables.  The tables with extended properties will also give this error in Microsoft Access 2007.  For the record, I am using SQL Server 2005 for this project.

The solution

What you need to do: open the table properties in Microsoft SQL Server Management Studio.
Then go the extended properties. 

image

 

When I deleted the MS_Filter, MS_OrderBy my problem was gone.

My Font BindingList

by Damiaan Peeters 2. December 2007 14:13

When you search a lot on MSDN, you might encounter from time to time a nice example.  Yesterday I found such a nice example on the BindingSource Class page.

They created a new new Generic BindingList of the Font Class

public class MyFontList : BindingList<Font>
{
    protected override bool SupportsSearchingCore
    {
        get { return true; }
    }
    protected override int FindCore(PropertyDescriptor prop, object key)
    {
        // Ignore the prop value and search by family name.         for (int i = 0; i < Count; ++i)
        {
            if (Items[i].FontFamily.Name.ToLower() == ((string)key).ToLower())
                return i;
        }
        return -1;
    }
}        

To use this class, just fill the MyFontList and attach it to a bindingSource.

MyFontList fonts = new MyFontList();
for (int i = 0; i < FontFamily.Families.Length; i++)
{
    if (FontFamily.Families[i].IsStyleAvailable(FontStyle.Regular))
        fonts.Add(new Font(FontFamily.Families[i], 11.0F, FontStyle.Regular));
}
binding1.DataSource = fonts;
listBox1.DataSource = binding1;
listBox1.DisplayMember = "Name";

BlogEngine.Net works with Windows Live Writer

by Damiaan Peeters 1. December 2007 12:40

Like a charm!  Just entered the blog address, my username and password.  Windows live writer discovered all the rest! 

image

The new look and features in Windows Live Writer (version 2008) are cool.  Let's see if BlogEngine.Net and Live writer can work with embedded images.

 

 

Who.I.am

Certified Umbraco, .net and Azure developer, seo lover. Magician in my spare time.

Month List