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


2 thoughts on “Data Binding with Binding Source- It really Sucks

  1. Wonderful site. Plenty of helpful information here.
    I’m sending it to several buddies ans additionally sharing in delicious. And certainly, thanks for your sweat!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s