?
Solved

UPDATE is not

Posted on 2004-11-18
5
Medium Priority
?
434 Views
Last Modified: 2012-05-05
Have VB.NET program

Used datset wizard, adapter wizard etc to set the stuff up.

I have code that adds rows to the one table in the dataset.
Then it updates the database, SQL
Except, when one queries the database/table there is nothing added to the table.

code to add rows

and if I step throw it, the rows do in  fact get added, column values filled etc.

Have:
Dataset.AcceptChanges
SQLDataAdapter.UpdateCommand.Connection.Open

Try
 SQLDataAdapter.Update(Dataset)
'actually tried various forms, overloads - no differences

Catch e As 'well one issue - which type of error to catch for
MsgBox(whatevererror is can catch)
end try

SQLDataAdapter.UpdateComman.Connection.Close

What happens as above, is no errors, no fouls.
Except, actually NO DATA gets written to the database.

If I comment out "...acceptchanges"
Then I get DBConcurrencyException
with no additional info.

As each datarow is unique - else I'd get errors adding/changing them during processing
Plus I have double checked that at the Try and they are in fact unique
The DBConcurrencyException tells me, and gee this is helpfull:
DBConcurrencyError
(0) rows affected.

Like that is helpful.

BTW: Right now there is nothing in the table on the database
But I use to have data (this table serves as temporary table, so once finished processing it deletes the data)
Point being I know the table works - is structured properly.

Any ideas?

Thanks.
0
Comment
Question by:tlfeet
  • 3
  • 2
5 Comments
 
LVL 5

Expert Comment

by:Hammadian2
ID: 12621212
if you're binding the dataset to a certain control
then u'll have to first call the EndEdit method of the control before trying to update data

if you're 100% sure that your code is correct, then try updating the framework to 1.1
0
 

Author Comment

by:tlfeet
ID: 12622401
Hi Hammadian2

re: "if you're binding the dataset to a certain control"

I am not binding this particular dataset to any controls.
But maybe I still need to do the begin/end edit routine?

re: "f you're 100% sure that your code is correct, then try updating the framework to 1.1"
Not 100% sure ... which is why I am posting. ;)
I am at 1.1

Thanks for ideas.
0
 
LVL 5

Accepted Solution

by:
Hammadian2 earned 2000 total points
ID: 12623132
post ur code
0
 

Author Comment

by:tlfeet
ID: 12626701
"post ur code"

Hi Hammadian2 - all of it?  All 600,000 lines - vast majority not having anything to do with UPDATE ;)
Seriously, what part?

Update is as above.

Private Sub()
Dataset.AcceptChanges
SQLDataAdapter.UpdateCommand.Connection.Open

Try
 SQLDataAdapter.Update(Dataset)
'actually tried various forms, overloads - no differences
 ' e.g. SQLDataAdapter.Update(Dataset, TableName) etc.

Catch e As 'well one issue - which type of error to catch for
'right now I have it set to catch DBConcurrencyException
'but have tried other errors
MsgBox(whatevererror is can catch)
End try

SQLDataAdapter.UpdateComman.Connection.Close
End Sub

If I have it as above, step thru, can check yes, indeed has rows, each row unique, etc.
Get to " SQLDataAdapter.Update(Dataset)" it does it, does not go into catch, does not throw some other error, but does not write to DB.

If I comment out "Dataset.AcceptChanges"
Then I get DBConcurrencyException Error
(0) Rows affected.

What other code are you looking for?
0
 

Author Comment

by:tlfeet
ID: 12662132
Problem stemmed from had a AcceptChanges line elsewhere in code (leftover from debuggin previously).
Which caused DBConcurrencyException, error.

Couldn't determine how to get more info out the Exception properties, methods.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question