Solved

Update table using multiple datawindows and PFC

Posted on 2004-08-16
1
792 Views
Last Modified: 2013-12-26
Hi all,

The question title says it all;  how do I update one database table using multiple datawindows (pointing to the same table) and PFC?

Here is the situation (simplified):

1 window with the following:
  -  3 command buttons
  -  1 tab control with 2 tab pages
     -  On tabpage 1, there is 1 datawindow.
     -  On tabpage 2, there is a tab control with 5 tabpages.  Each tabpage has 1 datawindow

All the datawindows are pointing to 1 table.  There is a 'New' button that resets & inserts a row into the datawindows, allowing the user to enter a new thing.  

When the user clicks Apply, the program calls the pfc_Save function.  It results in an error (duplicate primary key) when it attempts to update the 1st datawindow on the 2nd tabpage.

I understand why it is giving me the error but need help with the solution.  Why it's giving me the error?  The first datawindow inserts a row into the table successfully.  However, the 2nd datawindow attempts to insert a row using the same primary key.  The 2nd datawindow should perform an update, not an insert.  Please help!

Questions?  Please ask.
0
Comment
Question by:colettim
1 Comment
 
LVL 18

Accepted Solution

by:
diasroshan earned 250 total points
ID: 11817645
hi,

what u need to do is change the status of the rows u need to update to Datamodified! which will create an update statement. The status of all ur dws in ur case is NewModified! and hence creating an insert  statement.

try the following to change the status of ur rows in datawindows other than dw_1.....

dwItemStatus l_status
l_status = dw_rpt.GetItemStatus(1, 0, Primary!)
IF l_status = NewModified! THEN
     dw_rpt.SetItemStatus(1, 0,Primary!, DataModified!)
END IF

do ask if u need more assistance...

Cheers,
Rosh
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…

914 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now