Solved

Update table using multiple datawindows and PFC

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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. …
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand column That will then direct you to their download page. From that p…
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…
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

636 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