|
-
May 24th, 2004, 02:03 AM
#1
Is DataBinding evil?
DataBinding was "evil" in VB6.
What about in VB.NET?
-
May 24th, 2004, 07:43 AM
#2
Generally thought to be a bad programming technique yeah.
I don't live here any more.
-
May 24th, 2004, 09:06 AM
#3
YES and NO. Depends what you're after. If you need to build quick presentation app than I wouldn't say it's but if you intend to use such technic in your "real time" application then .. well you know ...
-
May 24th, 2004, 09:36 AM
#4
I hate it. Breeds laziness and lack of understanding of using databases. I hand code everything.
-
May 24th, 2004, 10:05 AM
#5
Fanatic Member
Originally posted by Cander
I hate it. Breeds laziness and lack of understanding of using databases. I hand code everything.
Ought we to differentiate between using the toolbox objects (connection, command, etc) and wizards (data form wizard) which are tools to facilitate databinding from actual databinding? I agree that using the former is lazy and often does result in not understanding DBs and, to a greater extent, how things really work, but is not synonymous with databinding. To use the simplest of examples, in .Net you can databind to arrays, enums, etc - hardly lazy and in no way representative of a lack of DB knowledge.
I think the real question here is in a customers form for ex., are you using two-way databinding and data adapters or manually setting fields and updating the DB.
Thoughts?
Last edited by Briantcva; May 24th, 2004 at 10:50 AM.
-
May 24th, 2004, 12:50 PM
#6
Sleep mode
DataBinding sucks .
-
May 24th, 2004, 01:26 PM
#7
Hyperactive Member
Pirate,
In previous versions of VB I would agree with you completely . . . DataBinding sucked immensely. In .NET, the same cannot be said. I have read several books and more than a hand full of articles on ADO.NET and in all cases, for quick displaying of data in say a DataGrid or a ListBox, DataBinding was the preferred method. With regard to controls like TextBoxes where you would potentially be updating the data, it is far better to manually populate the data in these controls and then intercept a KeyPress or Changed event to indicate that the data had changed and then write the appropriate code to submit your changes back to the source.
So it depends on what you are doing (Displaying vs Modifying) with your data as to what methodology is appropriate.
-
May 24th, 2004, 01:42 PM
#8
Sleep mode
Databinding is against code reuse . I'm talking about complex databinding that involves that stupid databinding manager .
-
May 24th, 2004, 09:35 PM
#9
Frenzied Member
Ya'll can say whatever you want about databinding but me personally, I think its a godsend.
BTW I never ever use the databinding form wizard. I code everything by hand.
-
May 24th, 2004, 11:47 PM
#10
I'm glad that most here feel the way I felt when I read about it.
Now, here's the problem: A lot of the books out there are only teaching database access the databinding way. I'd really really appreciate it someone could point me to a link (perhaps a simple ADO.NET tutorial) where they teach databinding by hand.
OR, if someone could show me a sample that they may have made while learning ADO.NET.
-
May 25th, 2004, 06:56 AM
#11
Frenzied Member
There should be some sample on MSDN. When I first started doing .NET I never knew about databinding until I came here. I was hand coding everything for my data access.
-
May 25th, 2004, 02:41 PM
#12
Hyperactive Member
Ok I akm firmly in the databinding camp. I tend to use it as a matter of course, yes you have problems with deicmal amd null values (especially dates) but they are easily overcome, someone asked for an example of databinding by hand (which I alwys use, here is an example:
VB Code:
' Bind Tenancies data to Windows form
TextBox8.DataBindings.Add(New Binding("Text", ds2, "Tenancies.PropertyAdr"))
NumTxtBox1.DataBindings.Add(New Binding("Text", ds2, "Tenancies.NoMonths"))
CheckBox1.DataBindings.Add(New Binding("Checked", ds2, "Tenancies.LettingOnly"))
TextBox9.Text = Format(dr2("ExpiresOn"), "dd MMMM yyyy")
Dim b2 As Binding = New Binding("text", ds2, "Tenancies.Rent")
AddHandler b2.Parse, AddressOf CurrDec
AddHandler b2.Format, AddressOf DecCurr
DecTxtBox1.DataBindings.Add(b2)
ComboBox1.DataBindings.Add(New Binding("SelectedIndex", ds2, "Tenancies.PaymentFrequency"))
Dim b5 As Binding = New Binding("text", ds2, "Tenancies.InitRent")
AddHandler b5.Parse, AddressOf CurrDec
AddHandler b5.Format, AddressOf DecCurr
DecTxtBox2.DataBindings.Add(b5)
Dim b3 As Binding = New Binding("text", ds2, "Tenancies.Bond")
AddHandler b3.Parse, AddressOf CurrDec
AddHandler b3.Format, AddressOf DecCurr
DecTxtBox3.DataBindings.Add(b3)
Dim b4 As Binding = New Binding("text", ds2, "Tenancies.Contribution")
AddHandler b4.Parse, AddressOf CurrDec
AddHandler b4.Format, AddressOf DecCurr
DecTxtBox13.DataBindings.Add(b4)
TextBox10.Text = Format(dr2("NextRentDue"), "dd MMMM yyyy")
TextBox3.DataBindings.Add(New Binding("Text", ds2, "Tenancies.LeadTenant"))
TextBox4.DataBindings.Add(New Binding("Text", ds2, "Tenancies.PhoneMobile"))
TextBox5.DataBindings.Add(New Binding("Text", ds2, "Tenancies.PhoneWork"))
TextBox6.DataBindings.Add(New Binding("Text", ds2, "Tenancies.EmergencyContact"))
TextBox7.DataBindings.Add(New Binding("Text", ds2, "Tenancies.email"))
ComboBox5.DataBindings.Add(New Binding("SelectedIndex", ds2, "Tenancies.PayMethod"))
TextBox18.DataBindings.Add(New Binding("Text", ds2, "Tenancies.AccountName"))
TextBox20.DataBindings.Add(New Binding("Text", ds2, "Tenancies.SortCode"))
TextBox19.DataBindings.Add(New Binding("Text", ds2, "Tenancies.Account"))
RichTextBox1.DataBindings.Add(New Binding("Text", ds2, "Tenancies.Notes"))
Private Sub CurrDec(ByVal sender As Object, ByVal cevent As ConvertEventArgs)
If Not cevent.DesiredType Is GetType(Decimal) Then
Exit Sub
End If
cevent.Value = Decimal.Parse(cevent.Value.ToString, Globalization.NumberStyles.Currency, Nothing)
End Sub
Private Sub DecCurr(ByVal sender As Object, ByVal cevent As ConvertEventArgs)
If Not cevent.DesiredType Is GetType(String) Then
Exit Sub
End If
Try
cevent.Value = CType(cevent.Value, Decimal).ToString("##,###0.00")
Catch
' null value trap
End Try
End sub
Private Sub DatStr(ByVal sender As Object, ByVal cevent As ConvertEventArgs)
If Not cevent.DesiredType Is GetType(String) Then
Exit Sub
End If
Try
cevent.Value = CType(cevent.Value, Date).ToString("dd MMMM yyyy")
Catch
' null value trap
End Try
End Sub
Private Sub StrDat(ByVal sender As Object, ByVal cevent As ConvertEventArgs)
If Not cevent.DesiredType Is GetType(Date) Then
Exit Sub
End If
cevent.Value = Date.Parse(cevent.Value)
End Sub
hope this helps rather than confuses
Last edited by kleinma; Oct 7th, 2005 at 12:33 PM.
Reason: added vbcode tags
-
Oct 7th, 2005, 11:19 AM
#13
New Member
-
Oct 7th, 2005, 12:19 PM
#14
Re: Is DataBinding evil?
 Originally Posted by mendhak
DataBinding was "evil" in VB6.
What about in VB.NET?
I thing that DataBinding is for Ms Access, why should we do Access in VB ...
-
Oct 7th, 2005, 12:34 PM
#15
Re: Is DataBinding evil?
I have heard it has worlds of improvement from the days of VB6, but since I come from the time when databinding was a NO-NO, I do everything by hand. It allows for the most amount of control between your classes and your database data
-
Oct 7th, 2005, 12:35 PM
#16
Re: Is DataBinding evil?
Designtime databinding: This is when you drop components onto a form in the designer, connect to a database, then set the datbindings right in the designer. This is bad (in my opin).
Runtime databinding: Where you create the databindings on the fly, when the app is running. Nice thing about this is that it doesn't have to be to a datatable or a dataset. I've used RT databindings to link my various controls to a dataclass. cuts down on the code & errors. This is OK, again, just my opin.
-tg
-
Oct 7th, 2005, 04:14 PM
#17
Junior Member
Re: Is DataBinding evil?
is there a performance hit in databinding versus code?
-
Oct 7th, 2005, 05:01 PM
#18
Re: Is DataBinding evil?
Add another one for thinking databinding evil in vb6 and in .net it looks the same but everything I've seen is databinding like drag n drop. I want to do it manually like we did in vb6.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Oct 7th, 2005, 05:20 PM
#19
Frenzied Member
Re: Is DataBinding evil?
hummm...strange...
databinding in an OOP language...????
give me a break...
-
Oct 7th, 2005, 07:32 PM
#20
Re: Is DataBinding evil?
Think of all the time saved on mundane stuff with the use of databinding, time that otherwise can go to the more complex parts of the program. I am a recent convert to databinding and used to think it was evil (and to some degree still do) but it is a good productivity tool. Keep in mind that it is a 'tool', one of many, I think it should be used where appropriate (including the IDE features that wire it up for you). I can't bring myself to use it as much as some in my office but I do now use it -generally for read only things. The best thing I like about it is I can bind to objects not just data.
I haven't used the tools in 2005 that much yet but it seems like it has DataBinding down to almost what it should be. The whole BindingSourceManager thing is kind of cool.
For everyone else here that knows of the databinding changes in 2005, Will they change your opinion of databinding?
NOTE: For some parts of an application or simple projects I would be questioned why I did NOT use databinding at my current job. I also would have to have a good reason why I took time to do it by hand instead of via the IDE. They view it as a cost thing and there is no way I could do it by hand as fast (for simple things).
-
Oct 7th, 2005, 09:17 PM
#21
Re: Is DataBinding evil?
This seems to be related here...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|