在ASP.NET 2.0中使用FormView插入新记录 [英] Inserting a New Record with FormView in ASP.NET 2.0

查看:73
本文介绍了在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;-)

And now 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 now works as you expected?


/Flemming


这篇关于在ASP.NET 2.0中使用FormView插入新记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆