如何在 Borland Builder 中将数据插入到 TdxMemData 中

发布于 2024-08-18 00:31:16 字数 622 浏览 6 评论 0原文

我正在努力将数据插入到 TdxMemData 中,该数据通过 TDataSourse 链接到网格。 MemData(称为 PurchaseData)有 3 列:Date(日期)、Place(字符串)和 Value(货币)。 我有一个执行以下操作的按钮:

PurchaseData->Insert();
PurchaseData->FieldByName("Date")->Value = TDateTime::CurrentDate().DateString();
PurchaseData->FieldByName("Place")->Value = "";
PurchaseData->FieldByName("Value")->Value = 0.0f;
PurchaseData->Post();

单击一次,它会正常插入一行,并且数据出现在网格的新行中,但是当再次单击该按钮时,我会在 Insert() 上收到一个弹出窗口,显示“无法转换变体”将类型(Null)转换为类型(String)”。

我担心列的属性“KeyFields”在其组合中除了其他 3 个字段之外还显示字段“RecId”。我不记得创建过任何名为 RecId 的列,如果创建过,我会将其删除。我不知道它是什么,也找不到帮助。

I'm struggling to insert data into a TdxMemData which is linked to a grid by a TDataSourse.
The MemData -called PurchaseData- has 3 columns: Date (date), Place (string) and Value (currency).
I have a button that does the following:

PurchaseData->Insert();
PurchaseData->FieldByName("Date")->Value = TDateTime::CurrentDate().DateString();
PurchaseData->FieldByName("Place")->Value = "";
PurchaseData->FieldByName("Value")->Value = 0.0f;
PurchaseData->Post();

Clicked once, it inserts a row normally and the data appears in a new row of the grid, but when clicking the button again I get a popup on the Insert() saying "Could not convert variant of type (Null) into type (String)".

I'm worried about the fact that the property "KeyFields" of the columns shows in its combo the field "RecId" besides the other 3 fields. I don't remember creating any column called RecId and if I did, I removed it. I can't figure out what it is and could not find help neither.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

娇女薄笑 2024-08-25 00:31:16

我现在无法测试这个,但将其更改为这样可能会起作用

PurPurchaseData->FieldByName("Place")->Value = String("");

如果这不起作用,那将是您设置专栏的方式造成的。

im not in a place to test this right now but changing it to this might work

PurPurchaseData->FieldByName("Place")->Value = String("");

if that doesnt work you it will be in the way you have set up your columns.

尘曦 2024-08-25 00:31:16

我映射了网格的 OnSelectionChanged 事件并读取新选择的行中的数据。不幸的是,当调用PurchaseData->Insert() 时,会立即触发SelectionChanged 事件。在下一行设置新行的数据之前。我从读取的数据中得到 Null 并用它做了坏事,比如用它设置编辑->文本,从而在弹出窗口中显示消息。

I had mapped the event OnSelectionChanged of the grid and read the data in the newly selected row. Unfortunately when PurchaseData->Insert() is called, the SelectionChanged event is fired right away. before the new row's data is set by the next lines. I got Null from the data read and did Bad Things with it like setting an edit->Text with it, thus the message in the popup.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文