Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Updating one table in a two-table relationship

Posted on 2006-11-09
1
Medium Priority
?
173 Views
Last Modified: 2010-04-23
Hi all,

I have two related tables.
The first table holds member information, the second group information.
The member is part of a group (duh)
On startup, all my controls (unbound) are filled with correct data, and also my datagrid
When I add a new member, the data for the member table is saved, along with the key relating it to the second table.(groupID)
The actual updating is working OK, but immediately after the update, the line in the datagrid holding the info for the new member (row) is all screwed up.
It only shows nulls and second table data.
The datagrid is supposed to show only 1 column of the second table.

memberID | Name | Surname | Date | Group (2nd table)

When I close the app, and restart, the latest added record is displayed OK.

The datagrid is the only bound control. The members table has an autonumber for memberID.

This is my code :

        strSQL = "Select * from tblleden"
        Dim AddLid_DA As New OleDb.OleDbDataAdapter(strSQL, conn)
        Dim AddLid_DS As New DataSet
        Dim AddLid_DT As DataTable
        Dim AddLid_DR As DataRow
        Dim custCB As OleDb.OleDbCommandBuilder = New OleDb.OleDbCommandBuilder(AddLid_DA)
        AddLid_DA.Fill(AddLid_DS, "Lid")
        AddLid_DT = AddLid_DS.Tables("Lid")
        Try
            AddLid_DR = AddLid_DT.NewRow

            AddLid_DR("date") = TextBox13.Text
            AddLid_DR("groupid") = groupID
            AddLid_DR("Name") = TextBox13.Text
            AddLid_DR("SurName") = TextBox14.Text
            AddLid_DT.Rows.Add(AddLid_DR)
            Dim modified As DataRow() = AddLid_DS.Tables("Lid").Select(Nothing, Nothing, DataViewRowState.Added)
            AddLid_DA.Update(modified)
            da.Fill(ds, "Leden") --->ds = the original two-table dataset

Any suggestions?



0
Comment
Question by:JamesBrian
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 13

Accepted Solution

by:
newyuppie earned 1500 total points
ID: 17906352
is there an explicitly constructed relationship in VB NET on the original two-table dataset (ds)? is this dataset what you bind to the datagridview? whats the datagrid datasource and datamember props?
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

604 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