在表单视图的插入模式中,主键对用户隐藏。在底层访问数据库中,主键是自动编号。 单击自动生成的插入按钮会导致错误: "您试图将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插入新记录
发布评论