⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 90.htm

📁 水木清华的BBS文章
💻 HTM
字号:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>CTerm非常精华下载</title>
</head>
<body bgcolor="#FFFFFF">
<table border="0" width="100%" cellspacing="0" cellpadding="0" height="577">
<tr><td width="32%" rowspan="3" height="123"><img src="DDl_back.jpg" width="300" height="129" alt="DDl_back.jpg"></td><td width="30%" background="DDl_back2.jpg" height="35"><p align="center"><a href="http://bbs.tsinghua.edu.cn"><font face="黑体"><big><big>水木清华★</big></big></font></a></td></tr>
<tr>
<td width="68%" background="DDl_back2.jpg" height="44"><big><big><font face="黑体"><p align="center">         Delphi编程                            (BM: strayli FlyingBoy)          </font></big></big></td></tr>
<tr>
<td width="68%" height="44" bgcolor="#000000"><font face="黑体"><big><big><p   align="center"></big></big><a href="http://cterm.163.net"><img src="banner.gif" width="400" height="60" alt="banner.gif"border="0"></a></font></td>
</tr>
<tr><td width="100%" colspan="2" height="454"> <p align="center">[<a href="index.htm">回到开始</a>][<a href="15.htm">上一层</a>][<a href="91.htm">下一篇</a>]
<hr><p align="left"><small>发信人: strayli (stray), 信区: Delphi <br>

标  题:    A Technical View of Borland MIDAS Part II (6) <br>

发信站: BBS 水木清华站 (Thu Nov 12 22:19:15 1998) WWW-POST <br>

  <br>

Error Handling <br>

When working with remote data sets, there are going to be occasions when <br>

errors occur. For instance, if two users are accessing a table at the same <br>

time, then it is possible that they will both want to change the same record. <br>

In this case, the person who first performed the update would succeed in <br>

changing the record, while the second person would get an error. <br>

  <br>

Errors are passed back to a TClientDataSet and can be handled by responding <br>

to the OnReconcileErrorEvent. A detailed explanation of responding to errors <br>

would take up almost as many pages as I've written so far, so I will consider <br>

that topic beyond the scope of this paper. However, there is a simple <br>

solution to this whole problem that can be covered in just a few paragraphs. <br>

  <br>

  <br>

The trick to handling errors returned from an Application Server is to use a <br>

form stored in the Delphi Object Repository. To find the form in question, <br>

select File | New from the menu, turn to the Dialogs page, and opt to Copy <br>

the Reconcile Error Dialog. Save the dialog in the same directory as your <br>

current project, and remove it from the files that are automatically created <br>



at start up. To do this, choose Project | Options | Forms from the Delphi <br>

menu. <br>

  <br>

Add the Reconcile Error Dialog to the uses list of the appropriate form in <br>

your project. In many cases, this will be the main form for your project. Now <br>

add the following in response to an OnReconcileError event: <br>

  <br>

procedure TForm1.CustomerClientDataSetReconcileError( <br>

  <br>

DataSet: TClientDataSet; E: EReconcileError; UpdateKind: TUpdateKind; <br>

  <br>

var Action: TReconcileAction); <br>

  <br>

begin <br>

  <br>

Action:=HandleReconcileError(Dataset, UpdateKind, E); <br>

  <br>

end; <br>

  <br>

This one line function will launch the dialog you found in the Object <br>

Repository and give the user the ability to handle any errors, as shown in <br>

Figure 5. <br>

Figure 5. <br>

  <br>

  <br>

  <br>

Figure 5: The OnReconcile Error Dialog from the Delphi Object Repository as <br>

it appears at run time. <br>

  <br>

The grid in the center of the form tells the name of the field on which the <br>

error occured. The Modified Value is the value the client application wanted <br>

to insert into the record. The Conflicting value is the value the "other guy" <br>

who beat you to the update inserted into the record. The Original Value is <br>

the value the record had before either update was made. As you can see, the <br>

user has the option to Skip, Cancel, Correct, Refresh or Merge the data. <br>

  <br>

Needless to say, you can make all these changes, and access all these options <br>

by writing your own code. However, it probably makes more sense just to use <br>

this dialog, or to use the dialog as the basis for your own code. <br>

  <br>

That is all I want to say about the process of creating a client or server <br>

application. The rest of this paper will deal with connectivity issues. <br>

Remember that a pair of programs called CustOrdersClient and CustOrdersServer <br>

accompany this paper. If you are having trouble finding these examples, you <br>

can look for them on my web site: users.aol.com/charliecal. <br>



  <br>

  <br>

  <br>

-- <br>

※ 来源:·BBS 水木清华站 bbs.net.tsinghua.edu.cn·[FROM: 202.38.79.111] <br>

</small><hr>
<p align="center">[<a href="index.htm">回到开始</a>][<a href="15.htm">上一层</a>][<a href="91.htm">下一篇</a>]
<p align="center"><a href="http://cterm.163.net">欢迎访问Cterm主页</a></p>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -