COCIExampleDlg.cpp
上传用户:qiye66685
上传日期:2013-03-10
资源大小:49k
文件大小:16k
源码类别:

Oracle数据库

开发平台:

Visual C++

  1. // COCIExampleDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "COCIExample.h"
  5. #include "COCIExampleDlg.h"
  6. #include "ConnectDlg.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CAboutDlg dialog used for App About
  14. class CAboutDlg : public CDialog
  15. {
  16. public:
  17. CAboutDlg();
  18. // Dialog Data
  19. //{{AFX_DATA(CAboutDlg)
  20. enum { IDD = IDD_ABOUTBOX };
  21. //}}AFX_DATA
  22. // ClassWizard generated virtual function overrides
  23. //{{AFX_VIRTUAL(CAboutDlg)
  24. protected:
  25. virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  26. //}}AFX_VIRTUAL
  27. // Implementation
  28. protected:
  29. //{{AFX_MSG(CAboutDlg)
  30. //}}AFX_MSG
  31. DECLARE_MESSAGE_MAP()
  32. };
  33. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  34. {
  35. //{{AFX_DATA_INIT(CAboutDlg)
  36. //}}AFX_DATA_INIT
  37. }
  38. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  39. {
  40. CDialog::DoDataExchange(pDX);
  41. //{{AFX_DATA_MAP(CAboutDlg)
  42. //}}AFX_DATA_MAP
  43. }
  44. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  45. //{{AFX_MSG_MAP(CAboutDlg)
  46. // No message handlers
  47. //}}AFX_MSG_MAP
  48. END_MESSAGE_MAP()
  49. /////////////////////////////////////////////////////////////////////////////
  50. // CCOCIExampleDlg dialog
  51. CCOCIExampleDlg::CCOCIExampleDlg(CWnd* pParent /*=NULL*/)
  52. : CDialog(CCOCIExampleDlg::IDD, pParent)
  53. {
  54. //{{AFX_DATA_INIT(CCOCIExampleDlg)
  55. m_strTablename = _T("");
  56. m_strFieldName = _T("");
  57. m_strCondition = _T("");
  58. m_strFieldVal = _T("");
  59. m_strConFName = _T("");
  60. m_strConFVal = _T("");
  61. //}}AFX_DATA_INIT
  62. // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  63. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  64. }
  65. CCOCIExampleDlg::~CCOCIExampleDlg()
  66. {
  67. OCISessionEnd(svchp,errhp,authp,(ub4)0);
  68. OCIServerDetach(srvhp,errhp,OCI_DEFAULT);
  69. OCIHandleFree((dvoid*)srvhp,OCI_HTYPE_SERVER);
  70. OCIHandleFree((dvoid*)svchp,OCI_HTYPE_SVCCTX);
  71. OCIHandleFree((dvoid*)errhp,OCI_HTYPE_ERROR);
  72. OCIHandleFree((dvoid*)authp,OCI_HTYPE_SESSION);
  73. OCIHandleFree((dvoid*)stmthp,OCI_HTYPE_STMT);
  74. OCIHandleFree((dvoid*)dschp,OCI_HTYPE_DESCRIBE);
  75. }
  76. void CCOCIExampleDlg::DoDataExchange(CDataExchange* pDX)
  77. {
  78. CDialog::DoDataExchange(pDX);
  79. //{{AFX_DATA_MAP(CCOCIExampleDlg)
  80. DDX_Control(pDX, IDC_CO_CONFNAME, m_comConFNameCtrl);
  81. DDX_Control(pDX, IDC_COBFNAME, m_comboCtrl);
  82. DDX_Control(pDX, IDC_LIST_TABLEDATA, m_listCtrl);
  83. DDX_Control(pDX, IDC_LIST_TABLENAME, m_listTablename);
  84. DDX_LBString(pDX, IDC_LIST_TABLENAME, m_strTablename);
  85. DDX_CBString(pDX, IDC_COBFNAME, m_strFieldName);
  86. DDX_CBString(pDX, IDC_COMB_CONDITION, m_strCondition);
  87. DDX_Text(pDX, IDC_EFFIELDVAL, m_strFieldVal);
  88. DDX_CBString(pDX, IDC_CO_CONFNAME, m_strConFName);
  89. DDX_Text(pDX, IDC_EDIT1, m_strConFVal);
  90. //}}AFX_DATA_MAP
  91. }
  92. BEGIN_MESSAGE_MAP(CCOCIExampleDlg, CDialog)
  93. //{{AFX_MSG_MAP(CCOCIExampleDlg)
  94. ON_WM_SYSCOMMAND()
  95. ON_WM_PAINT()
  96. ON_WM_QUERYDRAGICON()
  97. ON_BN_CLICKED(IDC_BUT_CONNECTDB, OnButConnectdb)
  98. ON_BN_CLICKED(IDC_B_TABLESELECTOK, OnBTableselectok)
  99. ON_BN_CLICKED(IDC_BUT_QUERY, OnButQuery)
  100. ON_BN_CLICKED(IDC_BUT_DELETE, OnButDelete)
  101. ON_BN_CLICKED(IDC_BUT_UPTATE, OnButUpdate)
  102. //}}AFX_MSG_MAP
  103. END_MESSAGE_MAP()
  104. /////////////////////////////////////////////////////////////////////////////
  105. // CCOCIExampleDlg message handlers
  106. BOOL CCOCIExampleDlg::OnInitDialog()
  107. {
  108. CDialog::OnInitDialog();
  109. // Add "About..." menu item to system menu.
  110. // IDM_ABOUTBOX must be in the system command range.
  111. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  112. ASSERT(IDM_ABOUTBOX < 0xF000);
  113. CMenu* pSysMenu = GetSystemMenu(FALSE);
  114. if (pSysMenu != NULL)
  115. {
  116. CString strAboutMenu;
  117. strAboutMenu.LoadString(IDS_ABOUTBOX);
  118. if (!strAboutMenu.IsEmpty())
  119. {
  120. pSysMenu->AppendMenu(MF_SEPARATOR);
  121. pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  122. }
  123. }
  124. // Set the icon for this dialog.  The framework does this automatically
  125. //  when the application's main window is not a dialog
  126. SetIcon(m_hIcon, TRUE); // Set big icon
  127. SetIcon(m_hIcon, FALSE); // Set small icon
  128. // TODO: Add extra initialization here
  129. return TRUE;  // return TRUE  unless you set the focus to a control
  130. }
  131. void CCOCIExampleDlg::OnSysCommand(UINT nID, LPARAM lParam)
  132. {
  133. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  134. {
  135. CAboutDlg dlgAbout;
  136. dlgAbout.DoModal();
  137. }
  138. else
  139. {
  140. CDialog::OnSysCommand(nID, lParam);
  141. }
  142. }
  143. // If you add a minimize button to your dialog, you will need the code below
  144. //  to draw the icon.  For MFC applications using the document/view model,
  145. //  this is automatically done for you by the framework.
  146. void CCOCIExampleDlg::OnPaint() 
  147. {
  148. if (IsIconic())
  149. {
  150. CPaintDC dc(this); // device context for painting
  151. SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  152. // Center icon in client rectangle
  153. int cxIcon = GetSystemMetrics(SM_CXICON);
  154. int cyIcon = GetSystemMetrics(SM_CYICON);
  155. CRect rect;
  156. GetClientRect(&rect);
  157. int x = (rect.Width() - cxIcon + 1) / 2;
  158. int y = (rect.Height() - cyIcon + 1) / 2;
  159. // Draw the icon
  160. dc.DrawIcon(x, y, m_hIcon);
  161. }
  162. else
  163. {
  164. CDialog::OnPaint();
  165. }
  166. }
  167. // The system calls this to obtain the cursor to display while the user drags
  168. //  the minimized window.
  169. HCURSOR CCOCIExampleDlg::OnQueryDragIcon()
  170. {
  171. return (HCURSOR) m_hIcon;
  172. }
  173. void CCOCIExampleDlg::OnButConnectdb() 
  174. {
  175. // TODO: Add your control notification handler code here
  176. ErrorProc(errhp,OCIEnvInit(& envhp,OCI_DEFAULT,0,0));
  177. OCIHandleAlloc(envhp,(void**)& errhp,OCI_HTYPE_ERROR,0,0);
  178. OCIHandleAlloc(envhp,(void**)& srvhp,OCI_HTYPE_SERVER,0,0);
  179.     OCIHandleAlloc(envhp,(void**)& svchp,OCI_HTYPE_SVCCTX,0,0);
  180. OCIHandleAlloc(envhp,(void**)& authp,OCI_HTYPE_SESSION,0,0);
  181.     OCIHandleAlloc((dvoid*)envhp,(dvoid**)& dschp,OCI_HTYPE_DESCRIBE,0,0);
  182. OCIHandleAlloc((dvoid*)envhp,(dvoid**)& stmthp,OCI_HTYPE_STMT,0,0);
  183. CConnectDlg ConnDlg;
  184.     ConnDlg.m_strDBName="vwserver";
  185. ConnDlg.m_strUserName="";
  186. ConnDlg.m_strUserID="";
  187. if(ConnDlg.DoModal()==IDCANCEL) 
  188. {
  189.         MessageBox("DLG has been out!");
  190. return;
  191. }
  192. UpdateData(true);
  193. sword status;
  194. status=OCIServerAttach(srvhp,errhp,(unsigned char*)(LPCTSTR)ConnDlg.m_strDBName,
  195.                (sb4)strlen(ConnDlg.m_strDBName),OCI_DEFAULT);
  196. if(status!=0)
  197. {
  198.          MessageBox("Database has been found!");
  199. }
  200. ErrorProc(errhp,OCIAttrSet((dvoid*)svchp,(ub4) OCI_HTYPE_SVCCTX,
  201.   (dvoid*)srvhp,(ub4)0,OCI_ATTR_SERVER,errhp));
  202. LPCTSTR uid,pwd;
  203. uid=ConnDlg.m_strUserName;
  204. pwd=ConnDlg.m_strUserID;
  205. ErrorProc(errhp,OCIAttrSet(authp,OCI_HTYPE_SESSION,
  206. (dvoid*)uid,(ub4)strlen(uid),OCI_ATTR_USERNAME,errhp));
  207.     ErrorProc(errhp,OCIAttrSet(authp,OCI_HTYPE_SESSION,(dvoid*)pwd,
  208. (ub4)strlen(pwd),OCI_ATTR_PASSWORD,errhp));
  209.     
  210. //status=OCISessionBegin(svchp,errhp,authp,OCI_CRED_RDBMS,OCI_DEFAULT);//这句话连不上!
  211. ErrorProc(errhp,OCISessionBegin(svchp,errhp,authp,OCI_CRED_RDBMS,OCI_DEFAULT));
  212.     
  213. if(status==OCI_ERROR) 
  214. {
  215. MessageBox("Database has not been connected!");
  216. return;
  217. }
  218. status=OCIAttrSet(svchp,OCI_HTYPE_SVCCTX,(dvoid*)authp,0,OCI_ATTR_SESSION,errhp);
  219. if(status!=0) return;
  220. CString strSQL;
  221. text    textSQL[1024];
  222. strSQL="SELECT TABLE_NAME FROM USER_TABLES";
  223. wsprintf((char*)textSQL,"%s",strSQL);
  224. status=OCIStmtPrepare(stmthp,errhp,textSQL,
  225. strlen((char*)textSQL),OCI_NTV_SYNTAX,OCI_DEFAULT);
  226. ErrorProc(errhp,OCIStmtExecute(svchp,stmthp,errhp,(ub4)0,0,
  227. NULL,NULL,OCI_DEFAULT));
  228. // ub4 col_num;//还没有使用.
  229. ErrorProc(errhp,OCIParamGet(stmthp,OCI_HTYPE_STMT,
  230. errhp,(void**)& colhp,1));
  231. ErrorProc(errhp,OCIAttrGet(colhp,OCI_DTYPE_PARAM,
  232. &collen[0],0,OCI_ATTR_DATA_SIZE,errhp));
  233. ErrorProc(errhp,OCIAttrGet(colhp,OCI_DTYPE_PARAM,
  234. &coltype[0],0,OCI_ATTR_DATA_TYPE,errhp));
  235. colbuf[0]=(text*)new text[(int)collen[0]+1];
  236. ErrorProc(errhp,OCIDefineByPos(stmthp,&defhp[0],
  237. errhp,1,(ub1*)colbuf[0],collen[0]+1,SQLT_STR,
  238. &ind[0],0,0,OCI_DEFAULT));                      //defhp中的参数修改过!
  239. while((OCIStmtFetch(stmthp,errhp,1,OCI_FETCH_NEXT,
  240. OCI_DEFAULT))!=OCI_NO_DATA)
  241. {
  242. m_listTablename.AddString((char*) colbuf[0]);
  243. }
  244. delete colbuf[0];
  245. }
  246. void CCOCIExampleDlg::ErrorProc(dvoid *err, sword status)
  247. {
  248. CString str;
  249. sb4 errcode;
  250. text errbuf[512];
  251.     if(status==OCI_ERROR)
  252. {
  253. OCIErrorGet((dvoid*)errhp,(ub4)1,NULL,&errcode,errbuf,
  254.         (ub4)sizeof(errbuf),OCI_HTYPE_ERROR);
  255. str.Format("error:%dn error information:%sn",errcode,errbuf);
  256. AfxMessageBox(str);
  257. }
  258. }
  259. void CCOCIExampleDlg::OnBTableselectok() 
  260. {
  261. // TODO: Add your control notification handler code here
  262. TableName="";
  263. int item=m_listTablename.GetCurSel();
  264. m_listTablename.GetText(item,TableName);
  265. if(TableName=="")return;
  266. text textSQL[1024];
  267. sword status;
  268. status=wsprintf((char *)textSQL,"SELECT * FROM %s",TableName);
  269. if(OCI_SUCCESS!=OCIStmtPrepare(stmthp,errhp,textSQL,strlen((char *)textSQL),
  270. OCI_NTV_SYNTAX,OCI_DEFAULT))
  271. {
  272. ErrorProc(errhp,status);
  273. return;
  274. }
  275. if(OCI_SUCCESS!=OCIStmtExecute(svchp,stmthp,errhp,(ub4)0,0,NULL,NULL,OCI_DEFAULT))
  276. {
  277. MessageBox("SQL语句没有成功执行!");
  278. ErrorProc(errhp,status);
  279. return;
  280. }
  281. ub4 col_num;
  282.     
  283. ErrorProc(errhp,OCIAttrGet(stmthp,OCI_HTYPE_STMT,&col_num,0,OCI_ATTR_PARAM_COUNT,errhp));
  284. ColumnNumbers=(int)col_num;
  285. text *namep;
  286. ub4   sizep;
  287. text tempText[100];
  288. for(int i=0;i<(int)col_num;i++)
  289. {
  290. ErrorProc(errhp,OCIParamGet(stmthp,OCI_HTYPE_STMT,errhp,(void**)&colhp,ub4(i+1)));
  291. ErrorProc(errhp,OCIAttrGet(colhp,OCI_DTYPE_PARAM,&collen[i],0,OCI_ATTR_DATA_SIZE,errhp));
  292. ErrorProc(errhp,OCIAttrGet(colhp,OCI_DTYPE_PARAM,&coltype[i],0,OCI_ATTR_DATA_TYPE,errhp));
  293. if(coltype[i]==SQLT_DAT) collen[i]=30;
  294. colbuf[i]=(text*)new text[(int)collen[i]+1];
  295. ErrorProc(errhp,OCIAttrGet(colhp,OCI_DTYPE_PARAM,(dvoid*)&namep,(ub4*)&sizep,OCI_ATTR_NAME,errhp));
  296. strncpy((char*)tempText,(char*)namep,(size_t)sizep);
  297. tempText[sizep]='';
  298. ColName[i].Format("%s",tempText);
  299. }
  300. for(i=0;i<(int)col_num;i++)
  301. {
  302. if(OCI_SUCCESS!=OCIDefineByPos(stmthp,&defhp[i],errhp,i+1,(ub1*)colbuf[i],
  303. collen[i]+1,SQLT_STR,&ind[i],0,0,OCI_DEFAULT))
  304. {
  305. ErrorProc(errhp,status);
  306. return;
  307. }
  308. }
  309. int row=0;
  310. while(OCI_SUCCESS==OCIStmtFetch(stmthp,errhp,1,OCI_FETCH_NEXT,OCI_DEFAULT))
  311. {
  312. for(i=0;i<(int)col_num;i++)
  313. {
  314. ColVal[row][i]=colbuf[i];
  315. }
  316. row++;             
  317. }
  318. for(i=0;i<(int)col_num;i++)//problem has been solved!
  319. delete colbuf[i];
  320. m_listCtrl.ModifyStyle(NULL,LVS_REPORT);
  321. m_listCtrl.SetExtendedStyle(LVS_EX_FLATSB |LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
  322. m_listCtrl.SetFocus();
  323. int ColNumber=m_listCtrl.GetHeaderCtrl()->GetItemCount();
  324. for(i=0;i<ColNumber;i++)
  325. m_listCtrl.DeleteColumn(i);//change the original.(0->i)(my idea is right!)
  326. for(i=0;i<(int)col_num;i++)
  327. m_listCtrl.InsertColumn(i,ColName[i],LVCFMT_LEFT,60,0);
  328. m_listCtrl.DeleteAllItems();
  329. for(i=0;i<row;i++)
  330. {
  331. m_listCtrl.InsertItem(LVIF_TEXT|LVIF_STATE,i,ColVal[i][0],
  332. (i%2)==0?LVIS_SELECTED:0,LVIS_SELECTED,0,0);
  333. for(int j=1;j<(int)col_num;j++)
  334. m_listCtrl.SetItemText(i,j,ColVal[i][j]);
  335. }                                           //自己把参数写错了,以后遍尝的时候要特别小心!
  336. for(i=0;i<(int)ColumnNumbers;i++)
  337. m_comboCtrl.AddString(ColName[i]);
  338. for(i=0;i<(int)col_num;i++)
  339. m_comConFNameCtrl.AddString(ColName[i]);
  340. }
  341. void CCOCIExampleDlg::OnButQuery() 
  342. {
  343. // TODO: Add your control notification handler code here
  344.     UpdateData(TRUE);
  345. CString FieldName=m_strFieldName;
  346. CString strCondition=m_strCondition;
  347. CString strFieldVal=m_strFieldVal;
  348. sword status;
  349. text  textSQL[1024];
  350. wsprintf((char*)textSQL,"SELECT *FROM %s WHERE %s %s :CONDITION",
  351. TableName,FieldName,strCondition);
  352. if(status=OCIStmtPrepare(stmthp,errhp,textSQL,
  353. strlen((char*)textSQL),OCI_NTV_SYNTAX,OCI_DEFAULT))
  354. {
  355. ErrorProc(errhp,status);
  356. return;
  357. }
  358. text *textConVal;
  359. sb4   len;
  360. int strlength=strFieldVal.GetLength();
  361. textConVal=new text[strlength+1];
  362. wsprintf((char*)textConVal,"%s",strFieldVal);
  363. textConVal[strlength]='';
  364. len=strlen((const char*)textConVal)+1;
  365. if(status=OCIBindByName(stmthp,&bidhp[0],errhp,(text*) ":CONDITION",-1,
  366. (ub1 *)textConVal,len,SQLT_STR,0,0,0,0,0,OCI_DEFAULT))
  367. {
  368. ErrorProc(errhp,status);
  369. return;
  370. }
  371. if(status=OCIStmtExecute(svchp,stmthp,errhp,(ub4)0,0,NULL,NULL,OCI_DEFAULT))
  372. {
  373. ErrorProc(errhp,status);
  374. return;
  375. }
  376. ub4 col_num;
  377. ErrorProc(errhp,OCIAttrGet(stmthp,OCI_HTYPE_STMT,&col_num,0,OCI_ATTR_PARAM_COUNT,errhp));
  378. for(int i=0;i<(int)col_num;i++)
  379. {
  380. ErrorProc(errhp,OCIParamGet(stmthp,OCI_HTYPE_STMT,errhp,
  381. (void **)&colhp,ub4(i+1)));
  382. ErrorProc(errhp,OCIAttrGet(colhp,OCI_DTYPE_PARAM,&collen[i],0,
  383. OCI_ATTR_DATA_SIZE,errhp));
  384. ErrorProc(errhp,OCIAttrGet(colhp,OCI_DTYPE_PARAM,&coltype[i],
  385. 0,OCI_ATTR_DATA_TYPE,errhp));
  386. if(coltype[i]==SQLT_DAT)
  387. collen[i]=30;
  388. colbuf[i]=(text*)new text [(int)collen[i]+1];
  389. }
  390. for(i=0;i<(int)col_num;i++)
  391. {
  392. if(status=OCIDefineByPos(stmthp,&defhp[i],
  393. errhp,i+1,(ub1*)colbuf[i],collen[i]+1,SQLT_STR,&ind[i],0,0,OCI_DEFAULT))
  394. {
  395. ErrorProc(errhp,status);
  396. return;
  397. }
  398. }
  399. int row=0;
  400. while((OCIStmtFetch(stmthp,errhp,1,OCI_FETCH_NEXT,OCI_DEFAULT))!=OCI_NO_DATA)
  401. {
  402. for(i=0;i<(int)col_num;i++)
  403. {
  404. ColVal[row][i]="";
  405. if(ind[i]==-1)
  406. ColVal[row][i]="";
  407. else
  408. ColVal[row][i]=colbuf[i];
  409. }
  410.     row=row+1;
  411. }
  412. for(i=0;i<(int)col_num;i++)
  413. delete colbuf[i];
  414. m_listCtrl.DeleteAllItems();
  415. for(i=0;i<row;i++)
  416. {
  417. m_listCtrl.InsertItem(LVIF_TEXT|LVIF_STATE,i,ColVal[i][0],
  418. (i%2)==0?LVIS_SELECTED:0,LVIS_SELECTED,0,0);
  419. for(int j=1;j<(int)col_num;j++)
  420. m_listCtrl.SetItemText(i,j,ColVal[i][j]);
  421. }
  422. delete textConVal;
  423. }
  424. void CCOCIExampleDlg::OnButDelete() 
  425. {
  426. // TODO: Add your control notification handler code here
  427. UpdateData(TRUE);
  428. sword status;
  429. text textSQL[1024];
  430. wsprintf((char*)textSQL,"DELETE FROM %s WHERE %s %s :DelFieldVal",TableName,
  431.   m_strFieldName,m_strCondition);
  432. if(status=OCIStmtPrepare(stmthp,errhp,textSQL,strlen((char*)textSQL),      //没有执行!
  433. OCI_NTV_SYNTAX,OCI_DEFAULT))
  434. {
  435. ErrorProc(errhp,status);
  436. return;
  437. }
  438. text textColVal[20];
  439. sb4 len;
  440. int strlength=m_strFieldVal.GetLength();
  441. wsprintf((char*)textColVal,"%s",m_strFieldVal);
  442. textColVal[strlength]='';
  443. len=strlen((const char *)textColVal)+1;
  444. if(status=OCIBindByName(stmthp,&bidhp[0],errhp,(text *) ":DelFieldVal",
  445. -1,(ub1 *)&textColVal,len,SQLT_STR,0,(ub2*)0,(ub2*)0,(ub4)0,(ub4*)0,OCI_DEFAULT))
  446. {
  447. ErrorProc(errhp,status);
  448. return;
  449. }
  450. if(status=OCIStmtExecute(svchp,stmthp,errhp,(ub4)1,0,NULL,NULL,OCI_DEFAULT))
  451. {
  452. ErrorProc(errhp,status);
  453. return;
  454. }
  455. OnBTableselectok();
  456. }
  457. void CCOCIExampleDlg::OnButUpdate() 
  458. {
  459. // TODO: Add your control notification handler code here
  460.     UpdateData(TRUE);
  461. sword status;
  462. text textSQL[1024];
  463. wsprintf((char*)textSQL,"UPDATE %s SET %s =:UpDFieldVal WHERE %s =:KeyFieldVal",
  464. TableName,m_strFieldName,m_strConFName);
  465. if(status=OCIStmtPrepare(stmthp,errhp,textSQL,strlen((char *)textSQL),
  466. OCI_NTV_SYNTAX,OCI_DEFAULT))
  467. {
  468. ErrorProc(errhp,status);
  469. return;
  470. }
  471. text textColVal[20];
  472. sb4  len;
  473. int  strlength=m_strFieldVal.GetLength();
  474. wsprintf((char*)textColVal,"%s",m_strFieldVal);
  475. textColVal[strlength]='';
  476. len=strlen((const char *)textColVal)+1;
  477.     if(status=OCIBindByName(stmthp,&bidhp[0],errhp,(text*)":UpDFieldVal",-1,
  478. (ub1*)&textColVal,len,SQLT_STR,0,0,0,0,0,OCI_DEFAULT))
  479. {
  480. ErrorProc(errhp,status);
  481. return;
  482. }
  483. text textConColVal[20];
  484. strlength=m_strConFName.GetLength();
  485. wsprintf((char*)textConColVal,"%s",m_strConFVal);
  486. textConColVal[strlength]='';
  487. len=strlen((const char*)textConColVal)+1;
  488. if(status=OCIBindByName(stmthp,&bidhp[1],errhp,(text*)":KeyFieldVal",-1,
  489. (ub1*)&textConColVal,len,SQLT_STR,0,0,0,0,0,OCI_DEFAULT))
  490. {
  491. ErrorProc(errhp,status);
  492. return;
  493. }
  494.     if(status=OCIStmtExecute(svchp,stmthp,errhp,(ub4)1,0,NULL,NULL,OCI_DEFAULT))
  495. {
  496. ErrorProc(errhp,status);
  497. return;
  498. }
  499. status=OCITransCommit(svchp,errhp,(ub4)0);
  500. OnBTableselectok();
  501. }