【发布时间】:2011-03-21 18:43:47
【问题描述】:
我正在尝试通过转到 sqldatasource 属性“更新查询”并编写代码来更新我在 datagridview 中的数据,但它显示错误消息
“违反主键约束“PK_contact_master”。无法在对象“dbo.admission_table”中插入重复键。 该语句已终止。 "
请告诉我在datagridview中编辑数据并更新它的确切代码..
谢谢, 丘吉尔
更新:
Sql 代码:
Update admission_table
set registration_id=@registration_id,
name_of_degree=@name_of_degree,
fees_paid=@fees_paid,
hostel=@hostel,
hostel_fees=@hostel_fees,
name_of_student=@name_of_student,
Date_of_birth=@Date_of_birth,
nationality=@nationality,
gender=@gender,
address=@address,
phone_no=@phone_no,
e_mail=@e_mail,
date=@date
【问题讨论】:
-
向我们确切展示您现在拥有的代码,也许我们会这样做。
-
更新 admission_table 设置registration_id=@registration_id,name_of_degree=@name_of_degree,fees_paid=@fees_paid,hostel=@hostel,hostel_fees=@hostel_fees,name_of_student=@name_of_student,Date_of_birth=@Date_of_birth,nationality=@nationality ,gender=@gender,address=@address,phone_no=@phone_no,e_mail=@e_mail,date=@date
-
registration_id 列是我的表的主键,等于@registration_id 之后是我的表列的名称
标签: c# asp.net sql-server-2005