我越来越
“只有在使用列列表并且 IDENTITY_INSERT 为 ON 时,才能为表中的标识列指定显式值。”
无论我是否指定身份,完全相同的错误。我不想指定身份,也不会将其插入到至少我能看到的任何地方。这是我的(编辑,jcolebrand)“相关”C# 代码:
SqlConnection con = new SqlConnection(strcon);
this.getControls(this.Controls);
con.Open();
/* jcolebrand moved the sql query text further down, it's long */
SqlCommand cmd = new SqlCommand(query, con);
cmd = getVals(cmd);
cmd.Parameters.AddWithValue("event_link", DBNull.Value);
cmd.Parameters.AddWithValue("event_approved", DBNull.Value);
cmd.Parameters.AddWithValue("event_in_csi", DBNull.Value);
cmd.Parameters.AddWithValue("event_in_website", DBNull.Value);
cmd.Parameters.AddWithValue("date_added", DateTime.Now.ToString());
cmd.Parameters.AddWithValue("event_start_time1", DBNull.Value);
cmd.Parameters.AddWithValue("event_end_time1", DBNull.Value);
cmd.Parameters.AddWithValue("program", DBNull.Value);
cmd.Parameters.AddWithValue("event_owner", DBNull.Value);
cmd.ExecuteNonQuery();
con.Close();
String query = @"INSERT INTO [rec_serv].[dbo].[recserv_event1] (
event_name
, event_category
, event_location
, event_instructor
, event_start_date
, event_end_date
, event_start_time
, event_end_time
, event_deadline
, member_fee
, non_member_fee
, email
, registration
, minimum_size
, maximum_size
, waiting_list
, event_detail
, monday
, tuesday
, wednesday
, thursday
, friday
, saturday
, sunday
, number_handout
, color_handout
, size_handout
, number_poster
, color_poster
, size_poster
, listserv
, news_release
, web_banner
, visix_ad
, desired_displayed_date
, other1
, other2
, comment
, event_link
, event_approved
, event_in_csi
, event_in_website
, date_added
, extracomment
, receiptinfo
, program
, event_owner
, event_start_time1
, event_end_time1
) VALUES (
@event_name,
@event_category,
@event_location,
@event_instructor,
@event_start_date,
@event_end_date,
@event_start_time,
@event_end_time,
@event_deadline,
@member_fee,
@non_member_fee,
@email,
@registration,
@minimum_size,
@maximum_size,
@waiting_list,
@event_detail,
@monday,
@tuesday,
@wednesday,
@thursday,
@friday,
@saturday,
@sunday,
@number_handout,
@color_handout,
@size_handout,
@number_poster,
@color_poster,
@size_poster,
@listserv,
@news_release,
@web_banner,
@visix_ad,
@desired_displayed_date,
@other1,
@other2,
@comment,
@event_link,
@event_approved,
@event_in_csi,
@event_in_website,
@date_added,
@extracomment,
@receiptinfo,
@program,
@event_owner,
@event_start_time1,
@event_end_time1
);"