Data Binding with Binding Source- It really Sucks

This post is result of amazing tooth gnashing fact i came across, when binding some WinForms controls with Some Access table.
the Code i was using was just simple code as follows:

Dim adp as New OleDBDataAbapter("Select * …","Provider=…..")
Dim ds as New DataSet


The funny bugs start from here onwards only:
Now i added one BindingNavigator and added binded to BindingSource.
When i was clicking AddNew a blank record was coming but in UI the record selected was first records (This is not acceptable). Since it should point to new Blank record.
More funniest things are yet to come.

Now after filling the data in blank records, when i click save the record, it mingled up everything. Just messed up all. It overwritten the first record with new given values. ( if any one expected this). You are adding new record and it is overwritting the existing one, that too without given any notifications.

I dig-ed out this topic more in depth, because i had to find out what was going out-of-box. that i was not able to see. I decided to manually code all CRUD operations. I removed all link between AddNew,Delete ToolStrip Button from Operation they were performing behind scene. Then i manually all operations my-self.

No My dear it is now over. now i faced some really frustrating situation, that i  never expected. i guess any one will not able to guess also. The problems were :
(1) AddNew function was adding 2 records with same data ( Even though all data related coding done manually).
(2) Delete was deleting first row, instead current selected record.

Now Here comes the happy ending on this pathetic situation.
I dig-ed this situation, because it was impacting the next code deliverable i had ti provide. So i have tried with creating Typed Dataset for All database objects using Add new Datasource wizard. Everything went fine. Object were generated and I binded Typed data Objects to binding source. Now everything was going smoothly and all implicit CRUD operation were also going fine.

Later on i tested the same scenario with other database, i gone though same course-of -action. But with Creating Business Objects(DAL) and binding to Binding source was the only solution i found.

The Conclusive remark i want to give is that. Always try to bind Business objects with Binding Source. I guess this will really help somebody.

Ashu Fouzdar
.Net Developer


Generate DAL in just 5 minutes

Since past few months, i was driving some research for getting a powerful Data Access Layer, that can plug-in any sort of application and can provide powerful feature. Such as:-
(1). Transaction management.
(2). Support for pure Object based programming.( do not have any SQL interacts on developer end).
(3). Give flexibility to generate code automatically.
(4). Support for one-to-many and many-to-many sort of relations between database objects.
(5). Pluggable to any sort application i.e. Web, Standalone, Rich Client.
(6). Support for maximum databases.

I evaluated following DAL softwares.
(1).  EasyObjects.Net
(2).  nHibernate.
(3).  SubSonic.
(4).  CoolStorage.
(5).  DataObjects.NET
(6).  Sooda.
(7).  MyGeneration DOODS
(8).  Gentle.NET
(9).   voidSoft Datablock.
(10). And lastly Typed DataSet from Visual Studio IDE.

I am glad to share that almost every DAL library given above is Free-of-Cost, that comes with GPL or restrictive GPL license. Anyone can add these library to their application and generate small apps, within small fraction of time.

As i already mentioned i was driving this sort of research in sort of finding a good DAL that can fit in my requirements. After evaluating i came to conclusion that. The feature’s i was looking for are available in SubSonic 2.0.3. I never want to say that other DAL do not these feature’s (again, it depends on personal choice and type of evaluations anyone is doing). The most exiting feature i found while using Subsonic as DAL for my window applications are:
(1). Automated code generation using command-line utility sonic.exe.
for ex. sonic generate /server localhost /db AnyDB /generatedNamespace xxxxx.BusinessObjects /appendWith _ /out ".\BO"

(2). Attribute based support for XML serialization, and validation can also be added using attribute.
(3). Based on Proven Enterprise Library architecture.
(4). Support for Object based queries.
(5). Supports transaction facade.
(6). Support of maximum popular databases.
(7). One can define all database parameter’s in application configuration and can switch the database without changing a single line of code.

That’s all i was searching for my small applications. The only thing i came across is no support for table that do not have primary key’s at all.

Hope anybody will get help from this post.

Ashu Fouzdar
.Net Developer
Contact me at :