PowerBuilder:使用数据窗口插入数据
假设我有一个名为“test”的表,其中包含名为 test_id
、test_name
和 test_age
的三列。我使用了一个名为 :al_test_id
的检索参数来提示用户插入 ID 并在数据库中搜索相应的 ID 条目,如果找到,则将其显示给用户。现在,如果没有找到条目,那么我希望用户能够使用他/她作为检索参数输入的 id 插入新行。
我怎样才能做到这一点?
Suppose I have a table called 'test', into which there are three columns named test_id
, test_name
and test_age
. I have used a retrieval argument called :al_test_id
to prompt the user to insert an id and search the database for the corresponding id entries, and if found, display it to the user. Now if no entry is found, then I want the user to be able to insert a new row using the id that he/she entered as the retrieval argument.
How can I do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所以,这个问题有很多解决方案。这是一个。
在用户启动搜索时触发的事件中(注意 ii_TestID 是一个实例变量,其他变量声明是本地的,留给您):
我假设 UI 中没有按钮来添加新的测试结果,所以我们'一次只处理一个。如果要保存:
为什么我要等到最后一刻才设置 test_id?因此,我可以在窗口的 CloseQuery 事件中编写类似的代码:
如果我在 InsertRow() 之后立即更改了 test_id,则 ModifiedCount() 会立即将该行注册为更改,即使用户没有执行任何操作然而。没有什么比在我还没有进行任何更改时计算机提示我保存更改更烦人的了。
祝你好运,
特里。
So, there are many solutions to this problem. Here's one.
In an event fired when the user initiates a search (note ii_TestID is an instance variable, other variable declaration local and left to you):
I'm going to assume there's no button in the UI to add a new test result, so we'll be dealing with just one at a time. In the event to save:
Why am I leaving setting the test_id until the last minute? So I can code something like this in the CloseQuery event of the window:
If I had changed the test_id right after InsertRow(), then ModifiedCount() would have registered the row as changed right away, even though the user hadn't done anything yet. Nothing more annoying than having a computer prompt me to save my changes when I haven't made any.
Good luck,
Terry.