Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 6th, 2004, 08:39 AM
Registered User
 
Join Date: Oct 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default dataAdapter update problem

Hi,

I have some strange problems with the update of a dataadapter.

First, I read a row in a table, through a dataset :

     
Quote:
quote:da = New SqlDataAdapter(sql, conn)
Quote:
ds = New DataSet
da.Fill(ds, "MyTable")
da.SelectCommand.CommandText = "select * from address"
Dim sqlBuilder As SqlCommandBuilder = New SqlCommandBuilder(da)
da.InsertCommand = sqlBuilder.GetInsertCommand()
da.DeleteCommand = sqlBuilder.GetDeleteCommand()
da.UpdateCommand = sqlBuilder.GetUpdateCommand()

ta = ds.Tables("MyTable")

pka(0) = ta.Columns("address_id")
ta.PrimaryKey = pka

dim dr As DataRow

dr = ta.Rows.Find(1) 'get the address with id 1
Then I update a field :

     
Quote:
quote:dr("country_id") = system.dbnull.value


and now I commit the change :

     
Quote:
quote:da.update(ds)


But changes are not reflected in the database....

The update command doesn't work with this update. If country_id value is not null, it works...
I precise that country_id is nullable in the DB.

Thanks for any help.

Best regards.

Arthur
 
Old October 6th, 2004, 09:45 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

I think you need to add BeginEdit() and EndEdit() methods for it to register. So wrap the datarow change in between these methods and try that. Also make sure you aren't making a call to the AcceptChanges method before you do Update; that will cause it not to work too (Update calls AcceptChanges when done).

Brian





Similar Threads
Thread Thread Starter Forum Replies Last Post
update dataadapter karenai Visual Basic 2005 Basics 0 February 9th, 2008 10:46 PM
DataAdapter.Update puzzle wirerider ASP.NET 2.0 Basics 1 August 1st, 2006 06:57 PM
Datagrid.update() and DataAdapter.Update aarunlal ASP.NET 2.0 Professional 2 February 23rd, 2006 11:41 PM
DataAdapter.Update acts strangely oricalchis ADO.NET 0 September 21st, 2005 06:21 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.