Results 1 to 21 of 21

Thread: Is DataBinding evil?

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Is DataBinding evil?

    DataBinding was "evil" in VB6.

    What about in VB.NET?

  2. #2
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682
    Generally thought to be a bad programming technique yeah.
    I don't live here any more.

  3. #3
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132
    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 ...

  4. #4
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    I hate it. Breeds laziness and lack of understanding of using databases. I hand code everything.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  5. #5
    Fanatic Member
    Join Date
    May 2002
    Posts
    746
    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.

  6. #6
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    DataBinding sucks .

  7. #7
    Hyperactive Member CyberHawke's Avatar
    Join Date
    May 2004
    Location
    Washington DC
    Posts
    477
    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.

  8. #8
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Databinding is against code reuse . I'm talking about complex databinding that involves that stupid databinding manager .

  9. #9
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    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.

  10. #10

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    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.

  11. #11
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    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.

  12. #12
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Dublin (Ireland)
    Posts
    304
    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:
    1. ' Bind Tenancies data to Windows form
    2.         TextBox8.DataBindings.Add(New Binding("Text", ds2, "Tenancies.PropertyAdr"))
    3.         NumTxtBox1.DataBindings.Add(New Binding("Text", ds2, "Tenancies.NoMonths"))
    4.  
    5.         CheckBox1.DataBindings.Add(New Binding("Checked", ds2, "Tenancies.LettingOnly"))
    6.         TextBox9.Text = Format(dr2("ExpiresOn"), "dd MMMM yyyy")
    7.         Dim b2 As Binding = New Binding("text", ds2, "Tenancies.Rent")
    8.         AddHandler b2.Parse, AddressOf CurrDec
    9.         AddHandler b2.Format, AddressOf DecCurr
    10.         DecTxtBox1.DataBindings.Add(b2)
    11.         ComboBox1.DataBindings.Add(New Binding("SelectedIndex", ds2, "Tenancies.PaymentFrequency"))
    12.         Dim b5 As Binding = New Binding("text", ds2, "Tenancies.InitRent")
    13.         AddHandler b5.Parse, AddressOf CurrDec
    14.         AddHandler b5.Format, AddressOf DecCurr
    15.         DecTxtBox2.DataBindings.Add(b5)
    16.         Dim b3 As Binding = New Binding("text", ds2, "Tenancies.Bond")
    17.         AddHandler b3.Parse, AddressOf CurrDec
    18.         AddHandler b3.Format, AddressOf DecCurr
    19.         DecTxtBox3.DataBindings.Add(b3)
    20.         Dim b4 As Binding = New Binding("text", ds2, "Tenancies.Contribution")
    21.         AddHandler b4.Parse, AddressOf CurrDec
    22.         AddHandler b4.Format, AddressOf DecCurr
    23.         DecTxtBox13.DataBindings.Add(b4)
    24.        
    25.         TextBox10.Text = Format(dr2("NextRentDue"), "dd MMMM yyyy")
    26.         TextBox3.DataBindings.Add(New Binding("Text", ds2, "Tenancies.LeadTenant"))
    27.         TextBox4.DataBindings.Add(New Binding("Text", ds2, "Tenancies.PhoneMobile"))
    28.         TextBox5.DataBindings.Add(New Binding("Text", ds2, "Tenancies.PhoneWork"))
    29.         TextBox6.DataBindings.Add(New Binding("Text", ds2, "Tenancies.EmergencyContact"))
    30.         TextBox7.DataBindings.Add(New Binding("Text", ds2, "Tenancies.email"))
    31.         ComboBox5.DataBindings.Add(New Binding("SelectedIndex", ds2, "Tenancies.PayMethod"))
    32.         TextBox18.DataBindings.Add(New Binding("Text", ds2, "Tenancies.AccountName"))
    33.         TextBox20.DataBindings.Add(New Binding("Text", ds2, "Tenancies.SortCode"))
    34.         TextBox19.DataBindings.Add(New Binding("Text", ds2, "Tenancies.Account"))
    35.         RichTextBox1.DataBindings.Add(New Binding("Text", ds2, "Tenancies.Notes"))
    36.  
    37.  Private Sub CurrDec(ByVal sender As Object, ByVal cevent As ConvertEventArgs)
    38.         If Not cevent.DesiredType Is GetType(Decimal) Then
    39.             Exit Sub
    40.         End If
    41.         cevent.Value = Decimal.Parse(cevent.Value.ToString, Globalization.NumberStyles.Currency, Nothing)
    42.     End Sub
    43.     Private Sub DecCurr(ByVal sender As Object, ByVal cevent As ConvertEventArgs)
    44.         If Not cevent.DesiredType Is GetType(String) Then
    45.             Exit Sub
    46.         End If
    47.         Try
    48.             cevent.Value = CType(cevent.Value, Decimal).ToString("##,###0.00")
    49.         Catch
    50.             ' null value trap
    51.         End Try
    52. End sub
    53.  
    54.  Private Sub DatStr(ByVal sender As Object, ByVal cevent As ConvertEventArgs)
    55.         If Not cevent.DesiredType Is GetType(String) Then
    56.             Exit Sub
    57.         End If
    58.         Try
    59.             cevent.Value = CType(cevent.Value, Date).ToString("dd MMMM yyyy")
    60.  
    61.         Catch
    62.             ' null value trap
    63.         End Try
    64.     End Sub
    65.  
    66.  
    67.     Private Sub StrDat(ByVal sender As Object, ByVal cevent As ConvertEventArgs)
    68.         If Not cevent.DesiredType Is GetType(Date) Then
    69.             Exit Sub
    70.         End If
    71.         cevent.Value = Date.Parse(cevent.Value)
    72.  
    73.     End Sub

    hope this helps rather than confuses
    Last edited by kleinma; Oct 7th, 2005 at 12:33 PM. Reason: added vbcode tags

  13. #13
    New Member
    Join Date
    Oct 2005
    Posts
    1

    Re: Is DataBinding evil?

    it confuses

  14. #14
    Frenzied Member Zakary's Avatar
    Join Date
    Mar 2005
    Location
    Canada, Quebec, Montreal
    Posts
    1,654

    Re: Is DataBinding evil?

    Quote 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 ...
    Using VS 2010 on Fw4.0

  15. #15
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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

  16. #16
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  17. #17
    Junior Member
    Join Date
    Jan 2005
    Posts
    29

    Re: Is DataBinding evil?

    is there a performance hit in databinding versus code?

  18. #18
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  19. #19
    Frenzied Member zuperman's Avatar
    Join Date
    Dec 2000
    Location
    Portugal
    Posts
    1,033

    Re: Is DataBinding evil?

    hummm...strange...

    databinding in an OOP language...????

    give me a break...
    Help keep this forum clean: Remember to mark your thread as resolved · Search before you post · Remember to rate posts that help

    VS2010: Visual Studio 2010 Keybinding Posters
    · Service Pack 1
    Tools: GhostDoc - automatically generates XML documentation comments
    · NuGet package Manager · PowerCommands IDE extensions
    Source Control: ankhsvn - integration for SVN
    · Windows Shell Extension for Subversion

    Development Laptop: Intel Core i5 430M 2.26 GHz @ 2.53 GHz
    · 4096 MB, DDR3 PC3-8500F (533 MHz), Kingston · ATI Mobility Radeon HD 5470 · 15.6 @ 16:9, 1366x768 pixel, HD LED LCD

    I follow:
    JoelOnSoftware - A weblog by Joel Spolsky, a programmer working in New York City, about software and software companies
    ScottGu's Blog - Scott Guthrie works for Microsoft as the Product Manager of the .NET Framework
    Portugal-a-Programar - Portuguese Developers Community
    .NET Rocks! - is a weekly Internet audio talk show for .NET Developers.

    Programming Languages:
    C#
    · VB.NET · JAVA · PHP · Javascript
    Other:
    XML
    · HTML · CSS · JQuery · SQL



    *** Proudly Portuguese ***

  20. #20
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339

    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).

  21. #21
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Is DataBinding evil?

    This seems to be related here...
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width