PDA

Click to See Complete Forum and Search --> : textboxes bindings and dataset delema


ronlahav
Jan 30th, 2003, 05:29 AM
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

Athley
Jan 30th, 2003, 05:36 AM
I see what you are saying, but exactly what is your question? How to validate if you choose to use the 2nd example?

ronlahav
Jan 30th, 2003, 05:39 AM
my question which technique is better?> - prefared?
thanks for reply

Athley
Jan 30th, 2003, 12:42 PM
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.

ronlahav
Jan 31st, 2003, 01:05 AM
i really appreciate you pointed me a direction