Bound textbox and comboboxes question

  • Thread starter Thread starter Dave
  • Start date Start date
D

Dave

Hello all,

I have an SQL Server express 2005 database and a VB .net 2003
Win form application that accesses the database, I have created 3
datatables and have bound multiple textboxes to one datatable and have two
comboboxes bound to the other two datatables (Used as lookup), In the
comboboxes selectedvaluechanged event I set a bound textbox to the
comboboxes selected value then I store the changed record via a stored
procedure but it doesn't work (the record is unchanged) and there is no
error produced. However if after selecting the required item in the combobox
and the selectedvaluechanged event has fired, the correct value is displayed
in the textbox and then if I click into the textbox (without making any
changes) before updating the record it works, the database reflects the
change. I use a begin edit before changing the record as well as a end edit
before calling the update.

Can anyone point out where I'm going wrong ? or point me in the
right direction ?

Many thanks

Dave.
 
Dave, right before you call Update, insert
System.Diagnostics.Debug.Assert(dataSetName.HasChanges(), "There are no
changes present");

Let's see if the assertion passes or fails, this will point us in the
directoin of what's wrong.
 
Hello Mr. Ryan,

Thanks for your promt reply, please pardon my
ignorance but I haven't used datasets, I have just created datatables, is
this where I have gone wrong ? Should I have used datasets ? I have been
using the code snippets from David Sceppa's Microsoft ADO.NET book.

Thanks again.

Dave.
 
Datasets are simply collections of dataTables. Using dataTables is fine.
The only reason I recommend this is b/c it's the easiest way to check for
changes in Rowstate. Just for testing purposes, create a dataset, add the
table in question to it and run the Assert I mentioned above (this is just
for testing - otherwise you'll have to check each row which is a lot more
work).
 
Mr. Ryan,
Thankyou for your patience, I have managed to get my project
functioning by setting focus to the textbox before setting it's value to the
comboboxes selected value, I should have thought of this before, sorry to
have wasted any of your time.

Thanks again,

Dave.
 
Back
Top