“列'ID'不允许空值”从datagridview抛出异常 [英] "Column 'ID' does not allow nulls" exception throw from datagridview
问题描述
  在SQL Server中,我创建了一个名为"CodeType"的表,其中包含以下主列: 在Visual Studio 2005中,我创建了一个数据集(xsd文件),并拖动表" CodeType"从工具栏"到服务器资源管理器"。并将列ID设置为readonly = true,allownull = true。 然后我创建一个窗体并从前面的数据集中插入一个datagridview控件。 我希望让SQL Server帮助创建ID列的值。当我测试它时,出现错误"列'ID'不允许空值"。 稍后我更新数据集(xsd文件)的"插入"命令,然后再试一次,错误仍然存在。 您能帮忙解决这个问题吗? 谢谢, Phlics
嗨全部,
我在SQL服务器中创建了一个表,并且有一个名为"ID"的列,其类型为guid,默认值为newid()。此列也已设置为表的主键。
我还在前面的表格中在Visual Studio 2005中创建了一个类型化的数据集,然后在windows窗体中,使用datagridview控件向它显示和添加新记录(将ID列设置为只读) ,我希望SQL Server帮助设置ID列的值)。但是当我测试它时,在插入新记录之后,系统总是抛出异常来说明ID不能为空。
你能帮我解决这个问题吗?
谢谢,
Phlics
Hi , In SQL Server , I create a table named "CodeType" with following main column: In Visual Studio 2005 , I create a dataset (xsd file) , and drag the Table "CodeType" to it from toolbar "Server Explorer". And set the column ID as readonly = true , allownull = true. Then I create a windows form and insert a datagridview control from preceding dataset. My hope is to let SQL Server help to create the value for ID column. When I test it , the error "Column 'ID' does not allow nulls" appear. Later I update the "Insert" command of the dataset(xsd file) and try again, the error still occur. Would you please help to address the issue ? Thanks, Phlics
Hi All,
I created a table in SQL server and there is a column named "ID" which type is guid and default value is newid(). This column also been set to primary key of the table.
I also created a typed dataset in Visual Studio 2005 from preceding table , then in a windows form , used datagridview control to show and add new record to it(set the column of ID to readonly, I hope SQL Server help to set the value of ID column). But when I test it , after inserting a new record , the system always throw exception to say that the ID can not be null.
Would you please help me to address the issue ?
Thanks,
Phlics
这篇关于“列'ID'不允许空值”从datagridview抛出异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!