Bound vs Unbound controls - Which shoud I use?

emaduddeen

Well-known member
Joined
May 5, 2010
Messages
171
Location
Lowell, MA & Occasionally Indonesia
Programming Experience
Beginner
Hi Everyone,

Which should I use?

Bound controls that I bind with the properties after I create a DataSet in the designer"
OR
Unbound controls that I bind manually within code?

Also should I use the designer and drag a DataAdapter and DataSet on my Form or create them in code?

Can you tell me if one has advantages over the other?

Thanks.

Truly,
Emad
 
Personally i am never using designer when i am working on DB project.
I prefer to have a full control over the stuff and know exactly what's going on.
Adding the dataadapter and dataset objects from within designer makes me feel kinda stupid keeping me away from real programming.
My $0.02
 
Well the performance is certainly not the only thing that you should worry about.
As mentioned, Strongly typed datasets are not objects in the .NET. Rather they are, designer generated wrapper classes based upon a XSD structure and derives from a Dataset and the dataset's associated objects like the DataAdapter or DataTable.

As i already told you all of the code for these datasets is abstracted away from the developers (Additionally, a typed DataSet provides strongly typed methods, events, and properties. This means you can access tables and columns by name, instead of using collection-based methods.).

Means it's up to you :)

Typed DataSets (ADO.NET)
 
Last edited:
Hi,

Thanks for the useful information.

I asked the questions because I'm a unemployed Oracle Developer looking to step into the VB.Net door and was looking to see which way people are doing VB.Net with DataSets, etc.

It seems that hand coding is the way to go and I'll assume that most programming shops do it the manual way as you are doing.

Truly,
Emad
 
Well most of the time you will not need to use dataset though. Usually you write the select, update, delete etc. methods on your own.
For instance you bind gridview to DataTable and call the update/delete methods separately.
VB.NET:
Public Function SelectMyData() As DataTable
    Dim table As New Datatable
    Dim connection as New Sqlconnection("connectionstring")
    Try
       connection.Open()
       Dim command As SqlCommand = connection.CreateCommand
       command.CommandText = "sql select query"
       table.Load(command.ExecuteReader)
    Catch ex As Exception

    Finally
      connection.Close()
    End Try
    return table
End Function

Then you say:
VB.NET:
GridView1.DataSource = SelectMyData
GridView.DataBind()


Or this is how you write the update method:

VB.NET:
Public Sub UpdateMyData(ByVal id As Integer) 

    Dim connection as New Sqlconnection("connectionstring")
    Try
       connection.Open()
       Dim command As SqlCommand = connection.CreateCommand
       command.CommandText = "sql update query"
       command.Parameters.Add("@ID", Int).Value = id
       command.ExecuteNonQuery
    Catch ex As Exception

    Finally
      connection.Close()
    End Try
End Sub

Then you just say:
VB.NET:
UpdateMyData(x)

Once you get familiar with it you will never want to use Typed Datasets again.
 
I asked the questions because I'm a unemployed Oracle Developer looking to step into the VB.Net door and was looking to see which way people are doing VB.Net with DataSets, etc.

It seems that hand coding is the way to go and I'll assume that most programming shops do it the manual way as you are doing.

I wouldnt hire anyone who didnt use the tools they have to their full advantage; the whole "not in control" argument really doesnt wash with me - the dataset designer writes thousands of lines of GOOD code that is visible to anyone who can click the "Show All Files" button. If someone came to me claiming they could write better code faster, and that they were a productive and smart programmer, I would show them the door and thank them for their time

I'd be far more likely to hire a developer who recognises that some coding tasks involve menial, repetitive work, and that instead of doing those things manually, they would write a software that would help them write the code. If you have 1000 stored procedures to connect up, do you spend a week writing all the code, using whatever text editor copy paste tricks you can to speed it up, or do you spend 4 days writing a tool that get the procedure name and arguments from the DB, and then uses a simple loop to write the code in a few seconds?

I spend the 4 days, and I have a tool that is usable forever more

"If I had 24 hours to cut down a tree, I would spend 20 hours sharpening an axe"
 
Well most of the time you will not need to use dataset though. Usually you write the select, update, delete etc. methods on your own.
For instance you bind gridview to DataTable and call the update/delete methods separately.

Tell you what, I'll race you.. One db, two tables in mster/detail relationship, write an app that shows, updates and deletes the data therein.. I'll use the designer to generate a few hundred lines of good, secure, fast, reliable, type safe, modular, object oriented code in about 2 minutes. What will you generate? :)

..snipped code..

Once you get familiar with it you will never want to use Typed Datasets again.

Yeah, that code that you spend all that time writing though.. it's just a badly named, poorly implented version of the code the designer generates for you

The suggestion that a smart programmer wouldnt ever use typed datasets is as laughable as this:

VB.NET:
Class Person
  Public FirstName as Object
  Public LastName as Object
  Public Age as Object
  Public Address as Object
  Public DateOfBirth as Object
...
End Class

or worse:

VB.NET:
Class Person
  Public Info as Dictionary(Of Object, Object)
End Class

Person.Info("Age") = 26
Person.Info("Name") = "John"

Youre advising newbies to ignore the principles of object oriented programming when moving into VB.NET - exactly how much consideration are you giving to their future career, seriously?
 
Hi cjard,

Thanks for the comments about using the designers. I love those things.

Before I started using Visual Studio and Oracle, I was using Clarion. Clarion is a little known product that also has designers that generate code just like Oracle Forms does. With both of those products you can get from A to B with the designer (my preferred way) or by and coding everything. You place additional hand code into the application via embedded source code points in various positions of the whole form. An example was "pre-update" so you can do processes right before updating the database. They were also event driven like VB.Net is. Because my IT education is self taught, I started out and fell in love using the designer tools.

When I entered the work force, most of my bosses were OK with me doing that except when I had to go into other peoples hand coded work to fix bugs. Unfortunately, the last boss I had did most of the Oracle Forms in hand code and everything was not only buggy, but it corrupted the data as well. I somewhat knew what the form was supposed to do and I tried to get him to allow me to re-do it with mostly the designer which would cut out most of the hand coding to create it bug free, but no way was that to happen. In fact, I got fired for doing other forms with the designer. He forced all of us to create unmaintainable spaghetti code. Anyway, if I get the chance I would still use the designers whenever possible if I'm fortunate enough to find employment again.

I'm going to go over to the jobs section of vbdotnetforums to see if I can find employment there.

Thanks again.

Truly,
Emad
 
Wow the oldie attacks again. However your suggestion (if it was told without being aggressive and insulting) makes sense

Ah, I think we just have different perceptions and ways of speaking.. I'd have said I was being emphatic (I'm very keen to see that newbies are started off in the right ways and following the best tutorials) rather than insulting but you are of course free to ask a moderator to review it and if they contact me to say I was being out of line then I'll rephrase and bear in mind for the future :)
Cheers
 
Hi cjard,

Hey there. I recall seeing Clarion on the cover disc of a magazine I got way back when my PC was running Windows 95. I never used it, kinda wish I had now :)


When I entered the work force, most of my bosses were OK with me doing that except when I had to go into other peoples hand coded work to fix bugs. Unfortunately, the last boss I had did most of the Oracle Forms in hand code and everything was not only buggy, but it corrupted the data as well. I somewhat knew what the form was supposed to do and I tried to get him to allow me to re-do it with mostly the designer which would cut out most of the hand coding to create it bug free, but no way was that to happen. In fact, I got fired for doing other forms with the designer. He forced all of us to create unmaintainable spaghetti code.

He seems to have fallen into the trap of thinking that a designer hides the power and is used by people who don't know what theyre doing. You may never have convinced him that Microsoft Windows is just a "Designer" for "stupid" "lazy" people who cannot be bothered to learn assembler and write the code to store an MP3 on a hard disk by hand coding, or that Visual Studio itself is a "designer" just like Notepad is.. When you come to think about it, everything in computing that isnt you programming by moving wires on a breadboard, is a "designer" of sorts.. It's all layers upon layers, and if you use it right, it's great and it works first time every time.
But let that boss carry on being and believing what he likes because he is hanging the stone around his own neck, making software that takes long and is buggy; that sort of person is crushing your creativity, not setting it free.. You don't want to work for anyone like that, no matter what pay because it sucks the life out of you- and life is for enjoying
 
Back
Top