Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Update table using multiple datawindows and PFC

Posted on 2004-08-16
1
Medium Priority
?
826 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 1000 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

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…
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 perform CRUD operations on a MySql database.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

719 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