Solved

Update table using multiple datawindows and PFC

Posted on 2004-08-16
1
786 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
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…

705 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

21 Experts available now in Live!

Get 1:1 Help Now