Results 1 to 5 of 5

Thread: textboxes bindings and dataset delema

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2003
    Posts
    175

    Cool textboxes bindings and dataset delema

    hi there

    i use form in which i have several textboxes through which i want to update a table that located in a dataset (and from there i can update my database).
    i notice that i can do it with 2 technique


    1. to create datarow object array typed and like a new row in my Dataset.Table and by index to fill the object array with the .Text property of my textbox. i find it more easy because before i add the new row to my table i can check validations so that the user didnt misstype i can also check if the row is not exists in my dataset and then add it.

    Dim NewRow As DataRow = sCompanies1.T_Companies.NewRow
    NewRow(1) = TextBox1.Text
    checks()




    2. to databinding the row outomatically bounds to the appropriate empty row
    but!!! i cant trace validations unless the DataRelations in the dataset is "shouting" if you know what i mean....



    Me.TextBox1.DataBindings.Add(New Binding("Text", DsCompanies1, "T_Companies.comp_AddressHeb"))

    button for add new empty row in my dataset

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Me.BindingContext(DsCompanies1, "T_Companies").AddNew()

    End Sub



    button for add the row to my dataset

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

    Me.BindingContext(DsCompanies1, "T_Companies").EndCurrentEdit()

    End Sub

  2. #2
    Registered User
    Join Date
    Nov 2002
    Location
    Växjö, Sweden
    Posts
    314
    I see what you are saying, but exactly what is your question? How to validate if you choose to use the 2nd example?

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2003
    Posts
    175

    my question which technique is better?>

    my question which technique is better?> - prefared?
    thanks for reply

  4. #4
    Registered User
    Join Date
    Nov 2002
    Location
    Växjö, Sweden
    Posts
    314
    In my opinion that kinda depends on what you are working with and what you are aming for. Some examples.

    1. If you are going for a look and functionality much like forms in for example Access, I would sure use the latter as the bindingmanagerbase gives you the possibility to move around in recordsets and easy add and remove records.
    2. If you have a form with only textboxes with the sole purpose of adding one record to the database I would probably pick the prior.
    3. It's a bit harder in a case where the sole purpose of the form is to add one record but you have alot of comboboxes, listboxes, checkedlistboxes and such that are filled with data from relational tables in the database. Then it might be good to fill a typed dataset with all this info and create "in-assembly-relation" and other constraints to ensure data integrety and the use data binding. But still in some cases, maybe not.

    No real good answer there, but I hope it helped you a bit.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jan 2003
    Posts
    175

    thanks athely

    i really appreciate you pointed me a direction

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