-1

Can any one please help me how to Insert the data into database from window form. How to fetch the data to show on window form & same to update the data from database. I am looking for the code that contain sql query with in the code not from the quick select data window. I am very new in powerbuilder.I want to write a code fetch update data from the code any where & show anywhere.

Thanks

rahul jain
  • 143
  • 1
  • 3
  • 12

3 Answers3

1

I'm not quite sure about your question. Try going to this website http://powerbuilder.hyderabad-colleges.com.

Look for Datawindow control and Datawndow object topics. There are other ways to manipulate data in Powerbuilder like using Embeded SQL (stored procedure and cursors).

I hope this will help you.

  • 1
    This documentation is very outdated in some points (like the support for mac & unix and the requirement to have a 486 or a "fast" 28.8 modem...) but the basics of using a datawindow are unchanged. It could help a beginner provided that he manages to find the GUI equivalents of PB5/6 into a recent PB. Also, the parts talking about creating C++ classes with Watcom C++ are irrelevant nowadays. – Seki May 07 '14 at 09:16
  • Like in JAVA we can give the Query with in the code. Retrive the data from Object. PreparedStatement st = con.prepareStatement("select * from task4Table "); ResultSet r1=st.executeQuery(); So same like how can we fetch,update the data from the code not from the Data window. – rahul jain May 07 '14 at 11:37
  • The equivalent is what's called Embedded SQL in the documentation (as the responder suggests). However, using a DataWindow object will be better performing, more maintainable, reusable, etc.... Not only should the phrase "When in Rome, do as the Romans do" apply, but you should also ask why the Romans like doing it that way. – Terry May 07 '14 at 14:20
  • 1
    Just because Java is difficult to use doesn't mean you have make PowerBuilder difficult to use. – Roland Smith May 07 '14 at 14:29
  • Stick with Java might be better idea I think too dangerous to use a tool with this much power. – Rich Bianco Oct 16 '16 at 01:49
1

The whole point of the Datawindow is that it does all that work for you.

Retrieve data:

dw_1.Retrieve(arguments)

Update the database:

dw_1.Update()

Roland Smith
  • 957
  • 4
  • 7
0

I'm not understanding the question entirely you must be having trouble with a multi-table update they can be challenging for a new developer.

This will do an update into two tables I did it in a hurry so might be a syntax error or two.

// insert a row 
li_row = dw_1.insertrow(0)
dw_1.setitem(li_row, 'col1', 'try reading')
dw_1.setitem(li_row, 'col2', 'the PowerBuilder')
dw_1.setitem(li_row, 'col3', 'manual next time')

// do accept text left out for purposes of brevity

// Update first table and dont bother with another accepttext
// since weve already done one and dont set the updateflags
// so second half of update creates correct sql statement
li_rtn = dw_1.Update(false, false)
if li_rtn = 1 then
  dw_1.modify('tbl1_col1.Update = No')
  dw_1.modify('tbl1_col2.Update = No')
  dw_1.modify('tbl1_col3.Update = No')
  dw_1.modify('tbl1_id.Key = No')
  dw_1.modify("Datawindow.Table.updateable = 'tbl2'")
  dw_1.modify('tbl2_col1.Update = Yes')
  dw_1.modify('tbl2_col2_id.Key = Yes')
  li_rtn = dw_1.update(false, true)
  if li_rtn = 1 then
    commit using sqlca;
  else
    rollback using sqlca;
  end if
end if
// cleanup the temp recs
li_rowcount = dw_1.rowcount()
for li_row = li_rowcount to 1 step -1
   dw_1.deleterow(li_row)
next
dw_1.Update()
Rich Bianco
  • 4,141
  • 3
  • 29
  • 48