Simple update to a row in a table in a SQL Server database 
Author Message
 Simple update to a row in a table in a SQL Server database

I am using Visual Studio.net and trying to update a very
simple form.  The form consists of  (4) text boxes.  The
first text box, employeeid, is used by the user as an
input box.  Based on the value, a parameterized query is
used to select the (1) employeeid, (2) Last Name and (3)
First Name.  I am using a data adapter and dataset to
retrieve the data.  The text boxes are bound to the text
property using Visual Studio.Net.  

Let's say the user changes the first name from William to
Bill.  After making the change in the text box, the user
would click the Save command button.  On this clicked
event I have a statement that updates the data adapter.  

The problem is - nothing gets updated.  From what I have
read, Visual Studio takes care of updating the dataset
through its data binding architecture, as long as I have
bound the text boxes to the appropriate fields in the
datatable. (using visual studio's property list for each
text box).   I tried adding 'Accept Changes' but that
didn't work either.

Although the query only retrieves one row (for the
employeeid), I decided to put a navigation button there to
see if that has any effect.  And it turns out that when I
hit the navigation button, before hitting the 'save'
button, it updates all right.  But, in this case I don't
need the navigation button.  So there must be something
I'm forgetting.

There is probably a simple answer, but I just don't know
what it is --

Thanks for your help.  



Wed, 24 Aug 2005 07:38:48 GMT  
 Simple update to a row in a table in a SQL Server database
Hi Herman,

Have you set up insertcommand, deletecommand and updatecommand properties
for the dataadapter? If not, take a look at the commandbuilder class.

HTH

Greg Low
Brisbane, Oztralia


Quote:
> I am using Visual Studio.net and trying to update a very
> simple form.  The form consists of  (4) text boxes.  The
> first text box, employeeid, is used by the user as an
> input box.  Based on the value, a parameterized query is
> used to select the (1) employeeid, (2) Last Name and (3)
> First Name.  I am using a data adapter and dataset to
> retrieve the data.  The text boxes are bound to the text
> property using Visual Studio.Net.

> Let's say the user changes the first name from William to
> Bill.  After making the change in the text box, the user
> would click the Save command button.  On this clicked
> event I have a statement that updates the data adapter.

> The problem is - nothing gets updated.  From what I have
> read, Visual Studio takes care of updating the dataset
> through its data binding architecture, as long as I have
> bound the text boxes to the appropriate fields in the
> datatable. (using visual studio's property list for each
> text box).   I tried adding 'Accept Changes' but that
> didn't work either.

> Although the query only retrieves one row (for the
> employeeid), I decided to put a navigation button there to
> see if that has any effect.  And it turns out that when I
> hit the navigation button, before hitting the 'save'
> button, it updates all right.  But, in this case I don't
> need the navigation button.  So there must be something
> I'm forgetting.

> There is probably a simple answer, but I just don't know
> what it is --

> Thanks for your help.



Wed, 24 Aug 2005 15:44:10 GMT  
 Simple update to a row in a table in a SQL Server database
hi herman

i had exactly the same problem a few weeks ago.  it turns out that when you
make a change via the bound controls the changed values go into the proposed
value for the datarow and the rowstate doesn't actually change.  what this
means is that when your dataadapter looks at the record it does not realise
there are any changes to make.

what you need to do is before calling the dataadapter update is call
endedit() for the row.  incidentally this is what happens automatically when
you use navigation buttons to move to another record - which is why that
worked.

michael


Quote:
> I am using Visual Studio.net and trying to update a very
> simple form.  The form consists of  (4) text boxes.  The
> first text box, employeeid, is used by the user as an
> input box.  Based on the value, a parameterized query is
> used to select the (1) employeeid, (2) Last Name and (3)
> First Name.  I am using a data adapter and dataset to
> retrieve the data.  The text boxes are bound to the text
> property using Visual Studio.Net.

> Let's say the user changes the first name from William to
> Bill.  After making the change in the text box, the user
> would click the Save command button.  On this clicked
> event I have a statement that updates the data adapter.

> The problem is - nothing gets updated.  From what I have
> read, Visual Studio takes care of updating the dataset
> through its data binding architecture, as long as I have
> bound the text boxes to the appropriate fields in the
> datatable. (using visual studio's property list for each
> text box).   I tried adding 'Accept Changes' but that
> didn't work either.

> Although the query only retrieves one row (for the
> employeeid), I decided to put a navigation button there to
> see if that has any effect.  And it turns out that when I
> hit the navigation button, before hitting the 'save'
> button, it updates all right.  But, in this case I don't
> need the navigation button.  So there must be something
> I'm forgetting.

> There is probably a simple answer, but I just don't know
> what it is --

> Thanks for your help.



Wed, 24 Aug 2005 17:11:50 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Simple update to a row in a table in an SQL Server database

2. 2nd SQL Server update after update text field corrupts row - using RDO

3. Error: 40002 - 01S03: [Microsoft][ODBC SQL Server Driver]No rows updated or deleted

4. Error : 40002 - 01S03: [Microsoft][ODBC SQL Server Driver]No rows updated or deleted

5. SQL Server-Access: Update 1000 Rows

6. List SQL Server Servers, Databases and Tables

7. Detect New Row in SQL Server Table

8. Populating a DB-grid wit rows from large SQL server tables

9. Updating A SQL server table through DAO and ODBC In Access 2000

10. Updating attached SQL Server Tables

11. Acc2000: Access tables attached to SQL-Server won't update

12. Help me: Update SQL Server table through sqlDataAdapter...

 

 
Powered by phpBB® Forum Software