在ASP.NET 2.0中使用FormView插入新记录

编程入门 行业动态 更新时间:2024-10-25 01:31:23
本文介绍了在ASP.NET 2.0中使用FormView插入新记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在表单视图的插入模式中,主键对用户隐藏。在底层访问数据库中,主键是自动编号。 单击自动生成的插入按钮会导致错误: "您试图将Null值分配给不是的变量一个Variant数据类型。" 您是否必须以编程方式设置唯一的ID密钥,如果是这样,您将如何在Visual Web Developer中执行此操作? 表单视图链接到具有适当自动生成插入子句的访问数据源。 INSERT INTO [xcrlog]([rowID],[Date],[Distance], [划船])价值观(?,?,?,?) Thanx, Jim

解决方案

嗨Jim,在您报告后一小时遇到完全相同的问题;-) 现在我终于找到了解决方案这似乎有效: 只需从 中删除唯一ID键插入命令和corrospon ding? 在你的情况下,我从你的INSERT命令中删除了[RowID]和?, INSERT INTO [xcrlog]([Date],[Distance],[Rowed By])VALUES(?,?,?) 然后,Access会自动为唯一键字段赋值。 现在让我知道它是否按预期工作? / Flemming

In the insert mode of form view, the primary key is hidden from the user. In the underlying access database, the primary key is autonumber.Clicking the autogenerated insert button causes the error:"You tried to assign the Null value to a variable that is not a Variant data type."Do you have to programmatically set the unique ID key, and if so how would you do that in Visual Web Developer?The form view is linked to an access datasource with appropriate autogenerated insert clause.INSERT INTO [xcrlog] ([rowID], [Date], [Distance], [Rowed By]) VALUES (?, ?, ?, ?)Thanx,Jim

解决方案

Hi Jim,encountered exactly the same problem an hour after you reported it;-)Andnow I finally found a solution which seems to work:Just remove the unique ID key from your Insert command and the corrosponding ?In your case I have removed the [RowID] and a ?, from your INSERT command:INSERT INTO [xcrlog]([Date], [Distance], [Rowed By]) VALUES (?, ?, ?)Access will then automaticly assign a value to the unique key field.Let me know if it nowworks as you expected?/Flemming

更多推荐

在ASP.NET 2.0中使用FormView插入新记录

本文发布于:2023-11-11 06:27:42,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:NET   ASP   FormView

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!