home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / VSCPPv4.zip / VACPP / IBMCPP / HELP / DAXHDI.INF (.txt) < prev    next >
OS/2 Help File  |  1995-05-18  |  38KB  |  1,130 lines

  1.  
  2. ΓòÉΓòÉΓòÉ <hidden> About this Information ΓòÉΓòÉΓòÉ
  3.  
  4. The How Do I... information provides solutions to common tasks that you would 
  5. perform with the various components of VisualAge C++. Before you begin to use 
  6. this information, it would be helpful to understand how to navigate through it: 
  7.  
  8.      Use the Contents and Index facilities to locate topics. 
  9.      Use the Search facility to search the text of this document. 
  10.      Use hypertext links to acquire related information on the current topic. 
  11.       Hypertext links appear in a different color (which you can customize 
  12.       using the OS/2 Scheme Palette). For example, below there are two lists of 
  13.       hypertext links. By double-clicking on the text of the link or by 
  14.       pressing Enter on a highlighted link, you will open a panel of related 
  15.       information. To shift the focus to other links using the keyboard, use 
  16.       the Tab key. 
  17.  
  18.  For more information on using this help facility, see: 
  19.  
  20.      How to Use the Contents 
  21.      How to Obtain Additional Information 
  22.      How to Access and Use IPF Facilities 
  23.  
  24.  For more information, see: 
  25.  
  26.      Other Information You Might Find Helpful 
  27.      Communicating Your Comments to IBM 
  28.      Notices 
  29.      Trademarks 
  30.  
  31.  
  32. ΓòÉΓòÉΓòÉ <hidden> How to Use the Contents ΓòÉΓòÉΓòÉ
  33.  
  34. The Contents window is the first to appear. Some topics have a plus ( ) icon 
  35. beside them. This icon indicates that additional topics are available. 
  36.  
  37. To expand the Contents if you are using a mouse, click on the plus ( ) icon. If 
  38. you are using the keyboard, use the Up or Down Arrow key to highlight the 
  39. topic, and press the plus (+) key. To see additional topics for a heading with 
  40. a plus ( ) icon, click on the icon or highlight that topic and press the plus 
  41. (+) key. 
  42.  
  43. To view a topic, double-click on the topic (or press the Up or Down Arrow key 
  44. to highlight the topic, and then press the Enter key). 
  45.  
  46.  
  47. ΓòÉΓòÉΓòÉ <hidden> How to Obtain Additional Information ΓòÉΓòÉΓòÉ
  48.  
  49. After you select a topic, the information for that topic appears in a window. 
  50. Highlighted words or phrases indicate that additional information is available. 
  51. Certain words and phrases are highlighted in a different color from the 
  52. surrounding text. These are called hypertext terms. 
  53.  
  54. If you are using a mouse, double-click on the highlighted word. If you are 
  55. using a keyboard, press the Tab key to move to the highlighted word, and then 
  56. press the Enter key. Additional information then appears in a window. 
  57.  
  58.  
  59. ΓòÉΓòÉΓòÉ <hidden> How to Access and Use IPF Facilities ΓòÉΓòÉΓòÉ
  60.  
  61. Several choices are available for managing the information presented in this 
  62. document. There are three PullDown menus: the Services menu, the Options menu, 
  63. and the Help menu. 
  64.  
  65. The actions that are selectable from the Services menu operate on the active 
  66. window currently displayed on the screen. These actions include the following: 
  67.  
  68.  Placing Bookmarks 
  69.    You can set a placeholder so you can retrieve information of interest to 
  70.    you. 
  71.  
  72.  Searching for Information 
  73.    You can find occurrences of a word or phrase in the current topic, selected 
  74.    topics, or all topics. 
  75.  
  76.  Printing Information 
  77.    You can print one or more topics. You can also print a set of topics by 
  78.    first marking the topics in the Contents list. 
  79.  
  80.  Copying Information to a File 
  81.    You can copy a topic that you are viewing to the System Clipboard or to a 
  82.    file that you can edit. This method is particularly useful for copying 
  83.    syntax definitions and program samples into the application that you are 
  84.    developing. 
  85.  
  86.  Using the actions that are selectable from the Options menu, you can change 
  87.  the way your Contents list is displayed. To expand the Contents and show all 
  88.  levels for all topics, choose Expand all from the Options PullDown menu. You 
  89.  can also press the Ctrl, Shift and * keys together. 
  90.  
  91.  The actions that are selectable from the Help menu allow you to select 
  92.  different types of help information. 
  93.  
  94.  For information about any of the menu choices, highlight the choice in the 
  95.  menu and press F1. 
  96.  
  97.  
  98. ΓòÉΓòÉΓòÉ <hidden> Placing Bookmarks ΓòÉΓòÉΓòÉ
  99.  
  100. When you place a bookmark on a topic, it is added to a list of bookmarks you 
  101. have previously set.  You can view the list, and you can remove one or all 
  102. bookmarks from the list.  If you have not set any bookmarks, the list is empty. 
  103.  
  104. To set a bookmark, do the following: 
  105.  
  106.    1. Select a topic from the Contents. 
  107.    2. When that topic appears, select the Bookmark option from the Services 
  108.       menu. 
  109.    3. If you want to change the name used for the bookmark, type the new name 
  110.       in the field. 
  111.    4. Click on the Place radio button (or press the Up or Down Arrow key to 
  112.       select it). 
  113.    5. Click on OK (or select it and press Enter). The bookmark is then added to 
  114.       the bookmark list. 
  115.  
  116.  
  117. ΓòÉΓòÉΓòÉ <hidden> Searching for Information ΓòÉΓòÉΓòÉ
  118.  
  119. You can specify a word or phrase to be searched.  You can also limit the search 
  120. to a set of topics by first marking the topics in the Contents list. 
  121.  
  122. To search for a word or phrase in all topics, do the following: 
  123.  
  124.    1. Select the Search option from the Services menu. 
  125.    2. Type the word or words to be searched for. 
  126.    3. Click on All sections (or press the Up or Down Arrow keys to select it). 
  127.    4. Click on Search (or select it and press Enter) to begin the search. 
  128.    5. The list of topics where the word or phrase appears is displayed. 
  129.  
  130.  
  131. ΓòÉΓòÉΓòÉ <hidden> Printing Information ΓòÉΓòÉΓòÉ
  132.  
  133. You can print one or more topics, the index, or the table of contents.  Make 
  134. sure that your printer is connected to the serial port, configured correctly, 
  135. and ready for input. To print: 
  136.  
  137.    1. Select Print from the Services menu. 
  138.    2. Select what you want to print. Note that the This section and Marked 
  139.       sections choices are only available if you are viewing a topic or if you 
  140.       have marked topics, respectively.  To mark topics in the table of 
  141.       contents, press the Ctrl key and click on the topics, or use the arrow 
  142.       keys. 
  143.    3. Select Print to print what you've chosen on your printer. 
  144.  
  145.  
  146. ΓòÉΓòÉΓòÉ <hidden> Copying Information to a File ΓòÉΓòÉΓòÉ
  147.  
  148. You can copy a topic that you are viewing in two ways: 
  149.  
  150.      Copy copies the topic that you are viewing into the System Clipboard. If 
  151.       you are using a Presentation Manager (PM) editor (for example, the 
  152.       Enhanced Editor) that copies or cuts (or both) to the System Clipboard, 
  153.       and pastes to the System Clipboard, you can easily add the copied 
  154.       information to your program source module. 
  155.  
  156.      Copy to file copies the topic that you are viewing into a temporary file 
  157.       named TEXT.TMP. You can later edit that file by using any editor. 
  158.       TEXT.TMP is placed in the directory where your viewable document resides. 
  159.  
  160.  To copy a topic, do the following: 
  161.  
  162.    1. Expand the Contents list and select a topic. 
  163.    2. When the topic appears, select Copy to file from the Services menu. 
  164.    3. The system puts the text pertaining to that topic into the temporary file 
  165.       TEXT.TMP. 
  166.  
  167.  
  168. ΓòÉΓòÉΓòÉ <hidden> Other Information You Might Find Helpful ΓòÉΓòÉΓòÉ
  169.  
  170. The VisualAge C++ provides a number of online guides and references that we 
  171. hope you'll find helpful as you develop applications. This information 
  172. includes: 
  173.  
  174.      User's Guide information provides conceptual and usage information, 
  175.      Reference information is organized for quick access, and 
  176.      How Do I... information gives you specific instructions for performing 
  177.       common tasks. 
  178.  
  179.  You can get to this online information from the Information folder inside the 
  180.  main product folder. You can also get to it from the Help menu in any of the 
  181.  components of the product. 
  182.  
  183.  
  184. ΓòÉΓòÉΓòÉ <hidden> Communicating Your Comments to IBM ΓòÉΓòÉΓòÉ
  185.  
  186. If there is something you like, or dislike, about this document, please let us 
  187. know. You can use one of the methods listed below to send your comments to IBM. 
  188. Please be sure to include the complete title of the publication that you are 
  189. commenting on. For example, you would refer to the How Do I... information for 
  190. the Browser as: 
  191.   VisualAge C++ Browser: How Do I... for OS/2. 
  192.  
  193. The comments you send should only pertain to the information in this document 
  194. and its presentation. To request additional publications or to ask questions or 
  195. make comments about the functions of IBM products or systems, you should talk 
  196. to your IBM representative or your authorized IBM remarketer. 
  197.  
  198. When you send comments to IBM, you grant IBM a nonexclusive right to use or 
  199. distribute your comments in any way it believes appropriate without incurring 
  200. any obligation to you. 
  201.  
  202. You can send your comments to IBM in the following ways: 
  203.  
  204.      By mail to the following address: 
  205.  
  206.             IBM Canada Ltd. Laboratory
  207.             Information Development
  208.             2G/345/1150/TOR
  209.             1150 EGLINTON AVENUE EAST
  210.             NORTH YORK, ONTARIO
  211.             CANADA M3C 1H7
  212.  
  213.      By FAX to the following number: 
  214.  
  215.         -  United States and Canada: (416) 448-6161 
  216.         -  Other countries (+1) 416-448-6161 
  217.  
  218.      By electronic mail to one of the following IDs.  Be sure to include your 
  219.       entire network address if you wish to get a reply. 
  220.  
  221.         -  Internet: torrcf@vnet.ibm.com 
  222.         -  IBMLink: toribm(torrcf) 
  223.         -  IBM/PROFS: torolab4(torrcf) 
  224.         -  IBMMAIL: ibmmail(caibmwt9) 
  225.  
  226.  
  227. ΓòÉΓòÉΓòÉ <hidden> Notices ΓòÉΓòÉΓòÉ
  228.  
  229. Copyright International Business Machines Corporation, 1995. All rights 
  230. reserved. 
  231.  
  232. Note to U.S. Government Users - Documentation related to restricted rights - 
  233. Use, duplication, or disclosure is subject to restrictions set forth in GSA ADP 
  234. Schedule Contract with IBM Corp. 
  235.  
  236. This edition applies to Version 3.0 of IBM VisualAge C++ for OS/2 (30H1664, 
  237. 30H1665, 30H1666) and to all subsequent releases and modifications until 
  238. otherwise indicated in new editions.  Make sure you are using the correct 
  239. edition for the level of the product. 
  240.  
  241. This publication could include technical inaccuracies or typographical errors. 
  242. Changes are periodically made to the information herein; any such changes will 
  243. be reported in subsequent revisions. 
  244.  
  245. Requests for publications and for technical information about IBM products 
  246. should be made to your IBM Authorized Dealer or your IBM Marketing 
  247. Representative. 
  248.  
  249. When you send information to IBM, you grant IBM a nonexclusive right to use or 
  250. distribute the information in any ways it believes appropriate without 
  251. incurring any obligation to you. 
  252.  
  253. Any reference to an IBM licensed program in this publication is not intended to 
  254. state or imply that only IBM's licensed program may be used. Any functionally 
  255. equivalent product, program, or service that does not infringe any of IBM's 
  256. intellectual property rights may be used instead of the IBM product, program, 
  257. or service. Evaluation and verification of operation in conjunction with other 
  258. products, except  those expressly designated by IBM, is the user's 
  259. responsibility. 
  260.  
  261. IBM may have patents or pending patent applications covering subject matter in 
  262. this document.  The furnishing of this document does not give you any license 
  263. to these patents.  You can send license inquiries, in writing, to the IBM 
  264. Director of Licensing. IBM Corporation, 500 Columbus Avenue, Thornwood, NY, 
  265. 10594, USA. 
  266.  
  267. This publication contains examples of data and reports used in daily business 
  268. operations. To illustrate them as completely as possible, the examples include 
  269. the names of individuals, companies, brands, and products. All of these names 
  270. are fictitious and any similarity to the names and addresses used by an actual 
  271. business enterprise is entirely coincidental. 
  272.  
  273.  
  274. ΓòÉΓòÉΓòÉ <hidden> Trademarks and Service Marks ΓòÉΓòÉΓòÉ
  275.  
  276. The following terms used in this publication are trademarks or service marks of 
  277. IBM Corporation in the United States or other countries: 
  278.  
  279.  C/2                      C Set/2 
  280.  C Set ++                 Common User Access 
  281.  CUA                      IBM 
  282.  Operating System/2       OS/2 
  283.  Personal System/2        Presentation Manager 
  284.  PS/2                     VisualAge 
  285.  WorkFrame/2 
  286.  
  287.  Other company, product, and service names, which may be denoted by a double 
  288.  asterisk(**), may be trademarks or service marks of others. 
  289.  
  290.  
  291. ΓòÉΓòÉΓòÉ 1. See details about my database table or view ΓòÉΓòÉΓòÉ
  292.  
  293. If the table or view object is not yet in the client area: 
  294.  
  295.    1. Select Create Classes... from the File menu 
  296.    2. Select the DB2/2 database you want 
  297.    3. Select Connect 
  298.    4. Select the table or view you want 
  299.    5. Select Create class to create a class from the table or view 
  300.  
  301.  Then simply double-click on the table or view object you want to work with to 
  302.  open its settings notebook. (Or click Mouse Button 2 on the table or view 
  303.  object to see its pop-up menu, and then select Open settings.) 
  304.  
  305.  Note:  You cannot change any information in the table or view settings 
  306.  notebook. 
  307.  
  308.  
  309. ΓòÉΓòÉΓòÉ 2. Create or change tables or views ΓòÉΓòÉΓòÉ
  310.  
  311. You cannot change the actual table or view definition in Data Access Builder. 
  312. But you can customize the mapping between a table or view and its class. You 
  313. must do this in DB2/2. 
  314.  
  315. Note:  Before you can use tables or views in Data Access Builder, you must also 
  316. have access to them in DB2/2. 
  317.  
  318. Related Task: 
  319.  
  320.      Customize the mapping 
  321.  
  322.  
  323. ΓòÉΓòÉΓòÉ 3. Use the table or view object ΓòÉΓòÉΓòÉ
  324.  
  325. Each table object represents a single database table. Each view object 
  326. represents a view on a database table or tables. 
  327.  
  328. To see the pop-up menu for actions you can perform on a table or view, click 
  329. Mouse Button 2 on the object. 
  330.  
  331. To open the settings notebook for a table or view object, double-click on it. 
  332. (This is the same as selecting Open settings from the object's pop-up menu.) 
  333.  
  334. Related Task: 
  335.  
  336.      Change the layout of objects in the client area 
  337.      Create more than one class for a table or view object 
  338.  
  339.  
  340. ΓòÉΓòÉΓòÉ 4. Use the class object ΓòÉΓòÉΓòÉ
  341.  
  342. Each class object represents a class that Data Access Builder created from a 
  343. table or view you selected from an existing database. 
  344.  
  345. To see the pop-up menu for actions you can perform on a class, click Mouse 
  346. Button 2 on the object. 
  347.  
  348. To open the settings notebook for a class object, double-click on it. (This is 
  349. the same as selecting Open settings from the object's pop-up menu.) 
  350.  
  351. A class's settings notebook describes the properties of that class, such as its 
  352. attributes and methods. The class was created using certain default settings, 
  353. but you can change these in the settings notebook. 
  354.  
  355. When the settings are the way you want them, you can generate source code for 
  356. the class. And then you can view the source code files you generated. (The View 
  357. source... option appears on the class pop-up menu after you generate source 
  358. code for the class.) 
  359.  
  360. Note:  After generating source code for a class, you can use the settings 
  361. notebook to change the class, and to generate source code again if necessary. 
  362.  
  363. Related Task: 
  364.  
  365.      Change the layout of objects in the client area 
  366.      Know which of my classes have been generated 
  367.      See my source code after I've generated it 
  368.      Customize the mapping 
  369.  
  370.  
  371. ΓòÉΓòÉΓòÉ 5. Change the layout of objects in the client area ΓòÉΓòÉΓòÉ
  372.  
  373. You can change the following aspects of the layout of the table and class icons 
  374. the client area: 
  375.  
  376.      orientation of the icons (either horizontal or vertical) 
  377.      size of the icons (either small, medium or large) 
  378.  
  379.  To change the orientation of the icons in the client area: 
  380.  
  381.      Select Icon size from the View menu 
  382.      Select the type of layout you want 
  383.  
  384.  The orientation of the icons changes. 
  385.  
  386.  To change the size of the icons in the client area: 
  387.  
  388.      Select Icon size from the View menu 
  389.      Select the icon size you want 
  390.  
  391.  The size of the icons changes. 
  392.  
  393.  Related Tasks: 
  394.  
  395.      Use the table or view object 
  396.      Use the class object 
  397.  
  398.  
  399. ΓòÉΓòÉΓòÉ 6. Start Data Access Builder ΓòÉΓòÉΓòÉ
  400.  
  401. To start Data Access Builder, do any one of the following: 
  402.  
  403.      Select Database from the Project menu of your WorkFrame project. 
  404.      Select the Data Access Builder icon from the Tools folder in the C++ 
  405.       folder. Double click on the Data Access Builder icon. 
  406.      Type ICSDATA from the command line in your current directory. 
  407.  
  408.  
  409.      Type ICSDATA <FILENAME.DAX> on a command line in your target directory, 
  410.       if you know which file you want to resume work on. 
  411.      Click mouse button 2 on <FILENAME.DAX> file in a WorkFrame Project, then 
  412.       select Database from the pop-up menu. 
  413.  
  414.  
  415. ΓòÉΓòÉΓòÉ 7. Save my work ΓòÉΓòÉΓòÉ
  416.  
  417. To save all the information in your current session, select Save from the File 
  418. menu. All the information about all mappings in the client area is saved. 
  419.  
  420. To save all the information in your current session for the first time, or to 
  421. save the session to a file other than the one named in the title bar, select 
  422. Save as... from the File menu. Use .DAX as the file extension. 
  423.  
  424. Related Task: 
  425.  
  426.      Resume work on a saved session 
  427.  
  428.  
  429. ΓòÉΓòÉΓòÉ 8. Resume work on a saved session ΓòÉΓòÉΓòÉ
  430.  
  431. To resume work on a session that you saved, select Open... from the File menu. 
  432. All the information about all the mappings in that session is restored to the 
  433. client area. 
  434.  
  435. Note:  When a session is opened, Data Access Builder does not reconnect to the 
  436. database tables. This lets you resume work on a session at your convenience, 
  437. without having to have continual access to all your database tables. 
  438.  
  439. Related Tasks: 
  440.  
  441.      Save my work 
  442.      Recover when the database definitions change 
  443.  
  444.  
  445. ΓòÉΓòÉΓòÉ 9. Customize the mapping ΓòÉΓòÉΓòÉ
  446.  
  447. To customize the way a class is mapped to its table or view: 
  448.  
  449.    1. Click Mouse Button 2 on the class object to see its pop-up menu, and then 
  450.       select Open settings. (Or simply double-click on the class object to open 
  451.       its settings notebook.) 
  452.    2. Page through the notebook to see the default settings. 
  453.    3. Make the desired changes on the first two pages; the Methods pages are 
  454.       read-only. 
  455.  
  456.  If you want to reset all the values on the page to what they were when you 
  457.  last opened that notebook page, select Reset. 
  458.  
  459.  Related Information: 
  460.  
  461.      Changing the Mapping between a Table and a Class 
  462.  
  463.  
  464. ΓòÉΓòÉΓòÉ 10. Recover when the database definitions change ΓòÉΓòÉΓòÉ
  465.  
  466. Changes made to a DB2/2 database table are not automatically updated in Data 
  467. Access Builder. The only connection between the actual table and the Data 
  468. Access Builder object occurs once-when the object first appears in the client 
  469. area. 
  470.  
  471. So it is possible to open a saved session that contains old table definitions 
  472. and resume work on it. But if the changes to the database table or view are 
  473. substantial, your generated Data Access Builder code may no longer be usable. 
  474.  
  475. Note:  Some 'safe' updates to a table that normally will not affect your 
  476. generated code's viability are: adding a column, deleting an unmapped column, 
  477. or adding a foreign key. 
  478.  
  479. To get a fresh connection to the database table, do one of the following: 
  480.  
  481.      In the same session: 
  482.  
  483.         1. Delete the table object (which also deletes all classes mapped to 
  484.            it). 
  485.         2. Select Create classes... from File menu. 
  486.         3. Connect to the database again. 
  487.         4. Select the table or view again. 
  488.         5. Then select Create class again. 
  489.  
  490.      Start a new session: 
  491.  
  492.         1. Select New... from the File menu to start a new session. (You might 
  493.            want to save your old file for purposes of comparison.) 
  494.         2. Connect to the database again. 
  495.         3. Select that table or view again. 
  496.         4. Then select Create class again. 
  497.         5. Change the Class notebook accordingly. 
  498.  
  499.  Related Tasks: 
  500.  
  501.      Customize the mapping 
  502.  
  503.  
  504. ΓòÉΓòÉΓòÉ 11. Create a class from more than one database table ΓòÉΓòÉΓòÉ
  505.  
  506. To create a class from more than one database table or from parts of more than 
  507. one table: 
  508.  
  509.    1. In DB2/2, create a view from the tables or from the parts of tables you 
  510.       want to include. 
  511.    2. Then, in Data Access Builder, select Create Classes... from the File 
  512.       menu. 
  513.    3. Connect to the database, and select the view that you just created. 
  514.  
  515.  Note:  Doing this results in a class that cannot modify the tables. If the 
  516.  view is read-only: the Add, Update, and Delete methods will throw an 
  517.  exception. 
  518.  
  519.  
  520. ΓòÉΓòÉΓòÉ 12. Create more than one class for a table or view object ΓòÉΓòÉΓòÉ
  521.  
  522. If you already have a class mapped to a table or view object, and you want to 
  523. create another class for the same object: 
  524.  
  525.    1. Click Mouse Button 2 on the table or view object to see its pop-up menu. 
  526.    2. Select Create class from the pop-up menu. 
  527.    3. To customize the default mapping for the new class, double-click on the 
  528.       object to open its settings notebook. 
  529.  
  530.  Note:  This is an alternative to creating more than one view of a database 
  531.  table in DB2/2. 
  532.  
  533.  Related Task: 
  534.  
  535.      Customize the mapping 
  536.  
  537.  
  538. ΓòÉΓòÉΓòÉ 13. Customize my class once it's generated ΓòÉΓòÉΓòÉ
  539.  
  540. The source code that Data Access Builder generates is not intended to be edited 
  541. directly. You would lose all your changes if you generated code from the same 
  542. class again later. 
  543.  
  544. To customize a class before building it into a program, you should define a 
  545. derived class (a subclass) from the ones Data Access Builder created. You can 
  546. use WorkFrame, Visual Builder, or your text editor to do this. Then you can 
  547. safely make your changes to that derived class. 
  548.  
  549.  
  550. ΓòÉΓòÉΓòÉ 14. Use the generated code ΓòÉΓòÉΓòÉ
  551.  
  552. With Data Access Builder you can do the following: 
  553.  
  554.      Generate a Visual Builder part and use it in Visual Builder. 
  555.      Generate a Visual Builder part and use it in a C++ program. 
  556.      Generate IDL source and use it in a SOM program. 
  557.  
  558.  Select the following link to see a sample program in each of these three 
  559.  options. 
  560.  
  561.  Related Task: 
  562.  
  563.      Add data using the generated code 
  564.      Update data using the generated code 
  565.      Delete data using the generated code 
  566.      Retrieve data using the generated code 
  567.      Use the generated methods 
  568.      Work with multiple rows 
  569.  
  570.  Related Information: 
  571.  
  572.      Constructing Applications Using Data Access Builder and the Visual 
  573.       Builder 
  574.      Constructing an Application Using Data Access Builder and C++ 
  575.      Constructing an Application Using Data Access Builder and SOM 
  576.  
  577.  
  578. ΓòÉΓòÉΓòÉ 15. Write an application to connect to a database ΓòÉΓòÉΓòÉ
  579.  
  580. Connecting to a database is just one task your finished program must perform. 
  581. The whole process of accessing data in a DB2/2 database involves: connect, 
  582. access (add, update, delete, or retrieve), transact, and disconnect. 
  583.  
  584. There are three variations of connection to a database: 
  585.  
  586.    1. Visual Builder 
  587.    2. C++ 
  588.    3. SOM 
  589.  
  590.  Related Information: 
  591.  
  592.      Using Visual Builder Programs 
  593.      Using C++ Programs 
  594.      Using SOM Programs 
  595.  
  596.  
  597. ΓòÉΓòÉΓòÉ 16. Build my application once it's written ΓòÉΓòÉΓòÉ
  598.  
  599. You can build your application either through WorkFrame or from scratch on an 
  600. OS/2 command line. 
  601.  
  602. Open the WorkFrame project that holds you files. Use View  Tool setup to set 
  603. the option for your build action. (This is not necessary if you initially 
  604. copied your project from DAXSAMP Database DLL.) Choose Build from the Project 
  605. pull-down menu. 
  606.  
  607. Related Information: 
  608.  
  609.      Constructing Applications Using Data Access Builder and the Visual 
  610.       Builder 
  611.      Constructing an Application Using Data Access Builder and C++ 
  612.      Constructing an Application Using Data Access Builder and SOM 
  613.  
  614.  
  615. ΓòÉΓòÉΓòÉ 17. Create source code from a class ΓòÉΓòÉΓòÉ
  616.  
  617. To create source code from a class object in the client area: 
  618.  
  619.    1. Click Mouse Button 2 on the class object to see its pop-up menu. 
  620.    2. Select Generate  from the class pop-up menu. 
  621.  
  622.       This generates the default type of code (Visual Builder part or IDL 
  623.       source). By default, the files are named after the table or view, as is 
  624.       the class, to help you remember the association between them. The names 
  625.       can be changed using the settings notebook. 
  626.  
  627.       For a Visual Builder part, the generated files will have the following 
  628.       extensions: 
  629.           filenameY.CPP 
  630.           filenameV.HPP 
  631.           filenameV.MAK 
  632.           filenameV.SQC 
  633.           filenameV.VBE 
  634.           filenameV.DEF 
  635.  
  636.       For IDL source, the generated files will have the following extensions: 
  637.           filenameX.CPP 
  638.           filenameI.IDL 
  639.           filenameI.MAK 
  640.           filenameI.SQC 
  641.  
  642.  To change the type of code that Data Access Builder generates by default: 
  643.  
  644.      Temporarily, use the Generate conditional cascade, and select the other 
  645.       option. 
  646.      Permanently, select Generate options... from the Options menu., and 
  647.       select the other option. Then select Save as default in the Generate 
  648.       Options window. 
  649.  
  650.  Related Task: 
  651.  
  652.      See my source code after I've generated it 
  653.      Know which of my classes have been generated 
  654.  
  655.  
  656. ΓòÉΓòÉΓòÉ 18. Generate both kinds of source code from the same class ΓòÉΓòÉΓòÉ
  657.  
  658. You can generate two different kinds of source code (parts and IDL) from a 
  659. single class object, without having to create another one: 
  660.  
  661.    1. Click Mouse Button 2 on the class object to see its pop-up menu. 
  662.    2. Select Generate from the class pop-up menu. 
  663.  
  664.       This generates the default type of code (Visual Builder part or IDL 
  665.       source). The files are named after the table or view, as is the class, to 
  666.       help you remember the association between them. 
  667.  
  668.       For a Visual Builder part, the generated files will have the following 
  669.       extensions: 
  670.           filenameY.CPP 
  671.           filenameV.HPP 
  672.           filenameV.MAK 
  673.           filenameV.SQC 
  674.           filenameV.VBE 
  675.           filenameV.DEF 
  676.  
  677.       For IDL source, the generated files will have the following extensions: 
  678.           filenameX.CPP 
  679.           filenameI.IDL 
  680.           filenameI.MAK 
  681.           filenameI.SQC 
  682.    3. Repeat step 1, but select the other kind of source code. 
  683.  
  684.  The class settings notebook contains a page of methods that apply to each kind 
  685.  of source code. Double-click on the class object to open its settings 
  686.  notebook. Or click Mouse Button 2 on the object to see its pop-up menu, and 
  687.  then select Open settings. 
  688.  
  689.  Related Tasks: 
  690.  
  691.      See my source code after I've generated it 
  692.      Know which of my classes have been generated 
  693.  
  694.  
  695. ΓòÉΓòÉΓòÉ 19. See my source code after I've generated it ΓòÉΓòÉΓòÉ
  696.  
  697. To see the source files that Data Access Builder generates: 
  698.  
  699.    1. Click Mouse Button 2 on the class object to see its pop-up menu. 
  700.    2. Select View Source.... (This item is only available on the pop-up menu 
  701.       after source code has been generated.) 
  702.    3. Select from the View Source window the file or files you want to browse. 
  703.       (You cannot edit these files.) 
  704.  
  705.  Related Tasks: 
  706.  
  707.      Use the generated code 
  708.  
  709.  
  710. ΓòÉΓòÉΓòÉ 20. Know which of my classes have been generated ΓòÉΓòÉΓòÉ
  711.  
  712. You can tell by the class object's appearance whether code has been generated 
  713. for it, and which type of code: 
  714.  
  715.      This object (plain blue ball): 
  716.  
  717.       This is the original, ungenerated state. Code has not been generated yet. 
  718.       (Another clue is that the pop-up menu for the class object does not 
  719.       contain the View source... item until code has been generated.) 
  720.  
  721.      This object (blue ball with an orange puzzle piece on right side): 
  722.  
  723.       Has a Visual Builder part generated for it. 
  724.  
  725.      This object (blue ball with a green box on left side): 
  726.  
  727.       Has IDL source generated for it. 
  728.  
  729.      This object (blue ball with both an orange puzzle piece on right side and 
  730.       a green box on left side): 
  731.  
  732.       Has both kinds of source files generated for it. 
  733.  
  734.  If you modify the settings notebook after a class has been generated, the icon 
  735.  for the class will return to the ungenerated state (plain blue ball) because 
  736.  source has not been generated for the most recent settings changes. 
  737.  
  738.  Related Task: 
  739.  
  740.      Use the class object 
  741.  
  742.  
  743. ΓòÉΓòÉΓòÉ 21. Include my own SQL components in my program ΓòÉΓòÉΓòÉ
  744.  
  745. You can incorporate your own SQL components in your make or build. To do this: 
  746.  
  747.    1. Use your text editor to produce your own SQC files. 
  748.    2. Make sure the SQLPREP action options are set to what you require 
  749.    3. Set the database name to your target database. Use the Prompt check box 
  750.       to allow you to modify the database during your build. 
  751.    4. Specify your files in the makemake (this is automatic in a build). 
  752.  
  753.  Related Tasks: 
  754.  
  755.      Bind my application to a different database 
  756.      Change my SQLPREP/SQLBIND options 
  757.  
  758.  
  759. ΓòÉΓòÉΓòÉ 22. Bind my application to a different database ΓòÉΓòÉΓòÉ
  760.  
  761. To bind your application to a different database: 
  762.  
  763.    1. Ensure the tables and columns referenced are the same between the two 
  764.       databases. 
  765.    2. Use the /B option of the SQLPREP step when you build your application. 
  766.    3. Move the application .EXE file and the generated .BND files to the 
  767.       workstation with the new database. 
  768.    4. Use the SQLBIND option to bind each .BND file (including those generated 
  769.       by Data Access Builder) to the new database. 
  770.  
  771.  Related Tasks: 
  772.  
  773.      Include my own SQL components in my program 
  774.      Change my SQLPREP/SQLBIND options 
  775.  
  776.  
  777. ΓòÉΓòÉΓòÉ 23. Change my SQLPREP/SQLBIND options ΓòÉΓòÉΓòÉ
  778.  
  779. To change your SQLPREP/SQLBIND options: 
  780.  
  781.    1. Use WorkFrame to set up the Data Access Builder tools. 
  782.    2. Select View  Tool setup. 
  783.    3. To compile, select SQL Prep under the compile action. 
  784.    4. To bind, select SQL Bind under the bind action. 
  785.  
  786.  Related Tasks: 
  787.  
  788.      Include my own SQL components in my program 
  789.      Bind my application to a different database 
  790.  
  791.  
  792. ΓòÉΓòÉΓòÉ 24. Add data using the generated code ΓòÉΓòÉΓòÉ
  793.  
  794. Use the Add method to add a new row to a table. To use the Add method: 
  795.  
  796.    1. First set the value of each attribute for which you want to store data. 
  797.  
  798.       Use the set attribute method for each attribute. For example, if an 
  799.       object has five attributes, you will need to use the set attribute method 
  800.       five times, once per attribute. 
  801.  
  802.       For C++ programs, use set<Attribute>. For IDL programs, use 
  803.       _set_<Attribute>. You must replace <Attribute> with the actual attribute 
  804.       name. 
  805.    2. Then issue the Add method. This takes the values from the attributes and 
  806.       creates and adds new rows in your table. 
  807.  
  808.       Note:  If you want an attribute to be null, use the set<Attribute>ToNull 
  809.       method before adding. (You can use the is<Attribute>Nullable method first 
  810.       to determine whether an attribute can accept null values.) 
  811.  
  812.  To do this in Visual Builder with a Visual Builder part: 
  813.  
  814.    1. Use attribute-to-attribute connection to set the attribute values. Use 
  815.       the add() action to add the row to the database. Use the commit() action 
  816.       on the database connection to complete the transaction. 
  817.  
  818.  Related Tasks: 
  819.  
  820.      Use the generated methods 
  821.      Update data using the generated code 
  822.      Delete data using the generated code 
  823.      Retrieve data using the generated code 
  824.  
  825.  
  826. ΓòÉΓòÉΓòÉ 25. Update data using the generated code ΓòÉΓòÉΓòÉ
  827.  
  828. Use the Update method to update the data in an existing row. To use Update: 
  829.  
  830.    1. First identify the row which you want to update. To do this, set the 
  831.       value of the data identifier(s) with the value that corresponds to the 
  832.       value in the row to be updated. 
  833.    2. To update the values, set the values of the attributes other than the 
  834.       data identifiers with the new values using the set attribute method. 
  835.  
  836.       For C++ programs, use set<Attribute>. For IDL programs, use 
  837.       _set_<Attribute>. You must replace <Attribute> with the actual attribute 
  838.       name. 
  839.    3. Then update the row using the Update method. 
  840.  
  841.  Note:  If you try to update using an object that is read-only, the update will 
  842.  fail. (Use the isReadOnly method first to determine if an object is 
  843.  read-only.) 
  844.  
  845.  To do this in Visual Builder with a Visual Builder part: 
  846.  
  847.    1. Use attribute-to-attribute connection to set the attribute values. Use 
  848.       the update() action to add the row to the database. Use the commit() 
  849.       action on the database connection to complete the transaction. 
  850.  
  851.  Related Tasks: 
  852.  
  853.      Use the generated methods 
  854.      Add data using the generated code 
  855.      Delete data using the generated code 
  856.      Retrieve data using the generated code 
  857.  
  858.  
  859. ΓòÉΓòÉΓòÉ 26. Delete data using the generated code ΓòÉΓòÉΓòÉ
  860.  
  861. Use the Delete method to delete the data in an existing row. To use Delete: 
  862.  
  863.    1. First identify the row you want to delete. To identify the row, give 
  864.       values to all the attributes that are defined as data identifiers. 
  865.    2. Then use the Delete method to delete the row. 
  866.  
  867.       Note:  As a precaution, you can use the Retrieve method first to retrieve 
  868.       the values to verify it is the row you want to delete. 
  869.  
  870.  To do this in Visual Builder with a Visual Builder part: 
  871.  
  872.    1. Use attribute-to-attribute connection to set the attribute values. Use 
  873.       the delete() action to add the row to the database. Use the commit() 
  874.       action on the database connection to complete the transaction. 
  875.  
  876.  Related Tasks: 
  877.  
  878.      Use the generated methods 
  879.      Add data using the generated code 
  880.      Update data using the generated code 
  881.      Retrieve data using the generated code 
  882.  
  883.  
  884. ΓòÉΓòÉΓòÉ 27. Retrieve data using the generated code ΓòÉΓòÉΓòÉ
  885.  
  886. Use the Retrieve method to retrieve a row that matches the value or values 
  887. given to the attributes. If more than one row matches the values, an exception 
  888. will be thrown. 
  889.  
  890. To retrieve the value of an attribute, use <Attribute> method in C++ or 
  891. _get_<Attribute> method in SOM. To check if the value is null or not, use 
  892. is<Attribute>Null in C++ or _get_<Attribute>IsNull in SOM. 
  893.  
  894. To do this in Visual Builder with a Visual Builder part: 
  895.  
  896.    1. Use attribute-to-attribute connection to set the attribute values. Use 
  897.       the retrieve() action to add the row to the database. Use the commit() 
  898.       action on the database connection to complete the transaction. If you use 
  899.       the Manager class, the result is available on the sequence reference 
  900.       returned by the items attribute. 
  901.  
  902.  There are two other methods in the Manager class that allow you to read 
  903.  multiple rows: 
  904.  
  905.      Refresh retrieves all the rows into a sequence 
  906.      Select retrieves with a condition specified as an IString. 
  907.  
  908.  Related Tasks: 
  909.  
  910.      Use the generated methods 
  911.      Add data using the generated code 
  912.      Update data using the generated code 
  913.      Delete data using the generated code 
  914.  
  915.  
  916. ΓòÉΓòÉΓòÉ 28. Use the generated methods ΓòÉΓòÉΓòÉ
  917.  
  918. You can use the following methods with Visual Builder and C++ parts: 
  919.  
  920.      Add 
  921.      Update 
  922.      Delete 
  923.      Retrieve 
  924.      <Attribute>() 
  925.      set<Attribute>(attribute type) 
  926.      set<Attribute>(const Istring) 
  927.      is<Attribute>Nullable 
  928.  
  929.       Use this method to test whether an attribute can be set to null. It 
  930.       returns True if the attribute is nullable. 
  931.  
  932.  
  933.      is<Attribute>Null 
  934.  
  935.       Use this method to test whether an attribute is currently set to null. It 
  936.       returns True if the attribute is null. 
  937.  
  938.  
  939.      set<Attribute>ToNull 
  940.  
  941.       Use this method to set an attribute to null. An exception will be thrown 
  942.       if you try to use this method against an attribute which is not nullable. 
  943.  
  944.  
  945.      isReadOnly 
  946.  
  947.       Use this method to test whether an object is read-only. It returns True 
  948.       if the object is read-only. 
  949.  
  950.  
  951.      isDefaultReadOnly 
  952.  
  953.       Use this method to test whether an object is read-only by default. It 
  954.       returns True if the object is read-only by default. 
  955.  
  956.  
  957.      setReadOnly 
  958.  
  959.       Use this method to set an object to read-only or read/write. If you want 
  960.       an object to be set to read-only, pass True as the input parameter. If 
  961.       you want the object to be read/write, pass False as the input parameter. 
  962.       (Using False as the parameter is allowed only when the object is not 
  963.       read-only by default.) 
  964.  
  965.  
  966.      <Attribute>AsString 
  967.  
  968.  You can use the following methods with IDL source: 
  969.  
  970.      Add 
  971.  
  972.      Update 
  973.  
  974.      Delete 
  975.  
  976.      Retrieve 
  977.  
  978.      _set_<Attribute> 
  979.  
  980.      _get_<Attribute> 
  981.  
  982.      _get_DefaultReadOnly 
  983.  
  984.       Use this method to test whether an object is read-only by default. It 
  985.       returns True if the object is read-only by default. 
  986.  
  987.      _get_CurrentReadOnly 
  988.  
  989.       Use this method to test whether an object is read-only. It returns True 
  990.       if the object is read-only. 
  991.  
  992.      _set_CurrentReadOnly 
  993.  
  994.       Use this method to test whether an object is read-only. It returns True 
  995.       if the object is read-only. 
  996.  
  997.      _get_<Attribute>isNullable 
  998.  
  999.       Use this method to test whether an attribute can be set to null. It 
  1000.       returns True if the attribute is nullable. 
  1001.  
  1002.      _get_<Attribute>isNull 
  1003.  
  1004.       Use this method to test whether an attribute is currently set to null. It 
  1005.       returns True if the attribute is null. 
  1006.  
  1007.      _set_<Attribute>isNull 
  1008.  
  1009.       Use this method to set an attribute to null. An exception will be thrown 
  1010.       if you try to use this method against an attribute which is not nullable. 
  1011.  IDL doesn't have <Attribute>AsString or items. 
  1012.  
  1013.  Related Tasks: 
  1014.  
  1015.      Add data using the generated code 
  1016.      Update data using the generated code 
  1017.      Delete data using the generated code 
  1018.      Retrieve data using the generated code 
  1019.  
  1020.  
  1021. ΓòÉΓòÉΓòÉ 29. Work with multiple rows ΓòÉΓòÉΓòÉ
  1022.  
  1023. The data manipulation methods are divided in two classes. The first class, with 
  1024. the same name as the table, contains methods that will access a single row of 
  1025. data. The second class-called the Manager class for parts, and the Factory 
  1026. class for IDL-is used to manipulate multiple instances (or rows) of the first 
  1027. class. 
  1028.  
  1029.      Items 
  1030.      Select 
  1031.  
  1032.       Use the select method to retrieve a set of rows that meet a condition. 
  1033.       The condition is passed as a parameter. 
  1034.  
  1035.       Parts specific: Visually, this can be done by connecting to an entry 
  1036.       field for typing in queries. 
  1037.  
  1038.  
  1039.      Refresh 
  1040.  
  1041.       Use the refresh method to retrieve all the rows in a table. 
  1042.  
  1043.       Parts specific: Visually, this can be done by connecting the refresh 
  1044.       method to a list box to display the results. 
  1045.  
  1046.  Related Tasks: 
  1047.  
  1048.      Use the generated methods 
  1049.      Add data using the generated code 
  1050.      Update data using the generated code 
  1051.      Delete data using the generated code 
  1052.      Retrieve data using the generated code 
  1053.  
  1054.  
  1055. ΓòÉΓòÉΓòÉ 30. Connect to the Database ΓòÉΓòÉΓòÉ
  1056.  
  1057. To connect to the database: 
  1058.  
  1059.    1. Use the IDatastore part provided on VBDAX or the class library. (include 
  1060.       IDSMCON or WPD) 
  1061.    2. Use the connect action after specifying the database name, userid and 
  1062.       password (if not already logged on). 
  1063.  
  1064.  Related Tasks: 
  1065.  
  1066.      Complete a Transaction 
  1067.      Disconnect from the Database 
  1068.  
  1069.  
  1070. ΓòÉΓòÉΓòÉ 31. Logon to the Database ΓòÉΓòÉΓòÉ
  1071.  
  1072. To logon to my system: 
  1073.  
  1074.    1. Use UPM. 
  1075.    2. Logon /L userid /p:password or specify userid and password on the connect 
  1076.       to IDatastore. 
  1077.  
  1078.  Related Tasks: 
  1079.  
  1080.      Connect to the Database 
  1081.      Complete a Transaction 
  1082.      Disconnect from the Database 
  1083.      Logoff from the Database 
  1084.  
  1085.  
  1086. ΓòÉΓòÉΓòÉ 32. Complete a Transaction ΓòÉΓòÉΓòÉ
  1087.  
  1088. To complete a transaction: 
  1089.  
  1090.    1. Use commit() or rollback() action on IDatastore. 
  1091.  
  1092.  Related Tasks: 
  1093.  
  1094.      Disconnect from the Database 
  1095.  
  1096.  
  1097. ΓòÉΓòÉΓòÉ 33. Disconnect from the Database ΓòÉΓòÉΓòÉ
  1098.  
  1099. To disconnect from the database: 
  1100.  
  1101.    1. Use the disconnect() action on IDatastore. 
  1102.  
  1103.  Related Tasks: 
  1104.  
  1105.      Connect to the Database 
  1106.      Complete a Transaction 
  1107.      Logoff from the Database 
  1108.  
  1109.  
  1110. ΓòÉΓòÉΓòÉ 34. Logoff from the Database ΓòÉΓòÉΓòÉ
  1111.  
  1112. To logoff from the database: 
  1113.  
  1114.    1. If connect logged you on, disconnect logs you off. Otherwise, use logoff 
  1115.       /L. 
  1116.  
  1117.  
  1118. ΓòÉΓòÉΓòÉ 35. Use the Database Access Class Library in Visual Builder ΓòÉΓòÉΓòÉ
  1119.  
  1120. To use the Database Access Class Library in Visual Builder: 
  1121.  
  1122.    1. Load IBMCPP\DDE4VB\VBDAX.VBB 
  1123.    2. Add IDatastore to the non visual part of you application, or, add 
  1124.       IDSConnectCanvas to the IFrameWindow. 
  1125.  
  1126.  Related Information: 
  1127.  
  1128.      Constructing Applications Using Data Access Builder and the Visual 
  1129.       Builder 
  1130.