473,396 Members | 2,030 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Data Adapter update

Hi,

This is partial code. I am trying to update the table, but it is not working
and I am not sure why. Can you please help? I don't get any errors, but the
table is not updated. I am sure I am missing something

Thank you

Dim cnNewMember As SqlConnection = New
SqlConnection(Constants.ConnectionString)
Dim dsNewMember As New DataSet("NewMember")

Try
Dim daNewMember As New SqlDataAdapter( _
"SELECT * FROM tree_members", cnNewMember)
cnNewMember.Open()

daNewMember.Fill(dsNewMember)
Dim strAName As String = Response.Cookies("aname").Value
Dim strANickName As String = Response.Cookies("anickname").Value
Dim strFatherID As Integer =
CInt(Response.Cookies("fatherid").Value)
Dim strMotherID As Integer =
CInt(Response.Cookies("motherid").Value)

Dim drNewMember As DataRow

drNewMember = dsNewMember.Tables(0).NewRow
drNewMember.Item("aname") = strAName
drNewMember.Item("anickname") = strANickName
drNewMember.Item("fatherid") = strFatherID
drNewMember.Item("motherid") = strMotherID
dsNewMember.Tables(0).Rows.Add(drNewMember)

If dsNewMember.HasChanges Then
dsNewMember.AcceptChanges()
dsNewMember.Tables(0).AcceptChanges()
'Response.Write(dsNewMember.Tables(0).Rows.Item(1) )
daNewMember.Update(dsNewMember.Tables(0))
End If

Catch
.....
.....
--
Thank you
Please post only
Nov 19 '05 #1
1 1122
Where you have:

If dsNewMember.HasChanges Then
dsNewMember.AcceptChanges()
dsNewMember.Tables(0).AcceptChanges()
'Response.Write(dsNewMember.Tables(0).Rows.Item(1) )
daNewMember.Update(dsNewMember.Tables(0))
End If

you are AcceptingChanges before you update, and so telling it there are no
changes. What you should do is something like:

If dsNewMember.HasChanges Then
dim dtChanges as datatable =
dsNewMember.Tables(0).GetChanges()

daNewMember.Update(dtChanges)

dsNewMember.AcceptChanges()
dsNewMember.Tables(0).AcceptChanges()
End If

"!!bogus" <he***@microb.com> wrote in message
news:eh**************@TK2MSFTNGP14.phx.gbl...
Hi,

This is partial code. I am trying to update the table, but it is not
working
and I am not sure why. Can you please help? I don't get any errors, but
the
table is not updated. I am sure I am missing something

Thank you

Dim cnNewMember As SqlConnection = New
SqlConnection(Constants.ConnectionString)
Dim dsNewMember As New DataSet("NewMember")

Try
Dim daNewMember As New SqlDataAdapter( _
"SELECT * FROM tree_members", cnNewMember)
cnNewMember.Open()

daNewMember.Fill(dsNewMember)
Dim strAName As String = Response.Cookies("aname").Value
Dim strANickName As String =
Response.Cookies("anickname").Value
Dim strFatherID As Integer =
CInt(Response.Cookies("fatherid").Value)
Dim strMotherID As Integer =
CInt(Response.Cookies("motherid").Value)

Dim drNewMember As DataRow

drNewMember = dsNewMember.Tables(0).NewRow
drNewMember.Item("aname") = strAName
drNewMember.Item("anickname") = strANickName
drNewMember.Item("fatherid") = strFatherID
drNewMember.Item("motherid") = strMotherID
dsNewMember.Tables(0).Rows.Add(drNewMember)

If dsNewMember.HasChanges Then
dsNewMember.AcceptChanges()
dsNewMember.Tables(0).AcceptChanges()
'Response.Write(dsNewMember.Tables(0).Rows.Item(1) )
daNewMember.Update(dsNewMember.Tables(0))
End If

Catch
.....
.....
--
Thank you
Please post only

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: William | last post by:
After much frustration I was able to update my data store via code only. Using the data adapter was the only way I was able to set up all the objects written in my code. Basically, I cheated by...
9
by: Brad | last post by:
I have written some code to manipulate data/records in a MASTER (order header) and DETAIL (order details) tables. What I have written is too extensive to post but essentially trying to: 1....
9
by: Michael | last post by:
Hi, I have a large table. Normally, the user will need to see only the data from the past two years, but sometimes, they will need to go back further. I have a form with a datagrid, a...
7
by: GatorBait | last post by:
Hi all, I am having a problem with my data adapter update command. I have generated the data adapter in the IDE and then I built a dataset. The dataset can get changed in the program and I...
6
by: Arne Beruldsen | last post by:
I have a very simple Access data base. No new info is going to be added...the only changes are to existing fields. I have 2 tables both with one row each. I'm using vb.net. I can easily...
12
by: Randy | last post by:
Hi, Trying to pass along a table row delete to the datasource, but I'm crashing. Here is the code: Private Sub btnDeleteIngr_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles...
6
by: Suresh | last post by:
Hi All, I am fetching a dataset from the database under some condition. After this I create a data table. Traverse in the original dataset & add each row to created data table as it is through...
0
by: mwenz | last post by:
I am trying to update an Access table using OLEDB in VB.Net 2005. I can add rows but I cannot update them. Code to instantiate the Access database and table... Dim conn As New...
9
by: SAL | last post by:
Hello, I have a Dataset that I have table adapters in I designed using the designer (DataLayer). I have a business logic layer that immulates the DataLayer which may/may not have additional logic...
6
by: insirawali | last post by:
Hi all, I have this problem, i need to know is there a way i cn use the data adapter's update method in this scenario. i have 3 tables as below create table table1{ id1 int identity(1,1)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.