(Lviv community of .NET developers)

Recent posts

OracleDecimal and ODP.NET IConvertable exception

September 30, 2008 10:49 by alexk

Oracle ODP.NET

I'm working now on a new project that in internals use ODP.NET - ORACLE Data Provider for .NET and latest Oracle 11g.

First of all I want to mention that ODP.NET is a great disappointment for me. In writing of very simple a stupid code ODP give me so many issues that I start to think that ORACLE completely loose own mind and release very unstable library for developers. I loose 2 days for fighting with found issues and I hope my article will help others a lot.

Simple Scenario that does not work in ODP.NET

Let's start from the simple scenario: Create typed DataSet with several tables, infill dataset by the data and update database by that data. Primary keys of the rows must be updated by Adapter automatically on Update method call.

... >>>

Currently rated 5.0 by 3 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Полезные ссылки - Part 7

July 21, 2008 21:34 by alexk
C# avionic instrument controls By Chootair
http://www.codeproject.com/KB/miscctrl/Avionic_Instruments.aspx



Статья интересна "расжованной" тематикой поворота картинок, ну и конечно самими контролами.
... >>>

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Delete Old files from Command Line

January 29, 2008 11:23 by alexk

Very often administrator in any company have to solve simple problem: delete from server old files. How we can do this?

  1. Write command line script that will do this for us and run it periodically by windows scheduler service
  2. write custom application that will do the same
  3. find freeware or shareware with required functionality

In our case I want to introduce COMMAND LINE version of problem solving

... >>>

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Полезные ссылки - Part 4

October 9, 2007 07:03 by alexk

A Pure .NET Single Application Instance/Instancing Solution
http://www.codeproject.com/useritems/SingleInstancingWithIpc.asp

Интересное решение, позволяющее контролировать сколько инстансов запущенно, а также показывает, как сделать комуникацию между инстансами программ - передача данных между процессами. Построенно на Named Pipes + Mutex.
... >>>

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Hierarchy data on DB layer

October 2, 2007 01:56 by alexk

Hierarchy data on DB layer

Simple ways

ParentId-to-ChildId

  1. define primary key in table
  2. define ParentRef column that has the same data type as primary key has and allowed NULL;
ID Data ParentRef
1 some data NULL
2 node1 1
3 node11 2
4 node2 1

Pluses:

  • easy to implement
  • good structure where data accessed level by level;

Minuses:

  • very complex queries for data extracting; implementation of query "extract node and all it childs" become very complex;

Separator

  1. define separator that can not be used by user
ID Name
1 ArtfulBits
2 ArtfulBits.Test
3 ArtfulBits.Test.Data
4 ArtfulBits.Samples

Pluses:

  • easy to implement
  • easy to extract node and it childs

Minuses:

  • some times is very hard to define seprator
  • growing of Name column value can become a problem if required deep hierarchy;

Combination

  1. define primary key in table
  2. define ParentRef column that has the same data type as primary key has and allowed NULL;
  3. define special index column varchar()
ID Name ParentRef Index
1 node1 NULL NULL
2 node2 1 0001
33 node21 2 0001-0002
4 node211 33 0001-0002-0033
5 node22 2 0001-0002
99 nodeN 33 0001-0002-0033

Pluses:

  • combination of performance and DB space usage
  • easy to extract data in any suitable way

Minuses:

  • required DB trigger on table for update and delete operations

Example

Separator is "/" char. Used 4 (four) chars for index key storage;

CREATE TABLE Articles  
(  
  -- article tree-hierarchy  
  [ArticleID]        [int]             IDENTITY (1, 1)   NOT NULL ,  
  [ArticleParentRef] [int]                               NOT NULL ,  
  [ArticleNodeKey]   [nvarchar](100)                     NULL ,  
  -- article parts  
  [ArtTitle]         [nvarchar](200)                     NULL ,  
  [ArtShortText]     [nvarchar](600)                     NULL ,  
  [ArtText]          [nvarchar](2000)                    NULL ,  
  [ArtTextFormat]    [varchar] (10)                      NULL ,  
  -- article references  
  [ArtUserRef]       [int]                               NULL ,  
  [ArtBlogRef]       [int]                               NULL ,  
  [ArtLanguage]      [varchar] (4)                       NULL ,  
  [ArtTime]          [datetime]                          NULL ,  
    
  CONSTRAINT [PK_Articles] PRIMARY KEY CLUSTERED   
  (  
    [ArticleID] ASC 
  )  
)  
 
GO  
 
CREATE function dbo.fnGetArticleNodeKey( @ID int )  
  returns nvarchar(500)  
as 
begin 
  declare   
    @Key nvarchar(500),   
    @SubKey nvarchar(10),   
    @ParentID int 
 
  select @Key = N'' 
 
  while( @ID is not NULL )  
  begin 
    select @ParentID = ArticleParentRef from Articles where ArticleID = @ID  
 
    set @SubKey = N'/' + right( replicate( '0', 3 ) + cast( @ID as nvarchar( 6 ) ), 4 )  
      
    if( charindex( @SubKey + N'/', @Key ) <> 0 )  
      return NULL 
      
    set @Key = @SubKey + @Key 
    set @ID = @ParentID  
  end 
 
  return @Key 
end 
 
GO  
 
CREATE TRIGGER tg_Articles_NodeKey  
  ON dbo.Articles  
  FOR INSERTUPDATE 
AS BEGIN 
  if TRIGGER_NESTLEVEL( @@PROCID ) = 1  
  begin 
      
    if update( ArticleID ) or update( ArticleParentRef ) or update( ArticleNodeKey )  
    begin 
      
      update Articles set   
        ArticleNodeKey = dbo.fnGetArticleNodeKey( ArticleID )  
      where isNull( ArticleNodeKey, '' ) <> isNull( dbo.fnGetArticleNodeKey( ArticleID ), '' )  
 
      if exists( select * from Articles where ArticleNodeKey is NULL )   
      begin 
        raiserror( 'Recursion in Tasks', 16, 1 )  
        rollback tran  
        return 
      end 
    end 
  end 
END 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5