我正在尝试将信息插入到 sql express 2008 数据库上的表中,当我尝试插入字段时,我收到错误“''附近的语法不正确'”有人可以向我解释一下我的代码中的原因是什么问题?
protected void insertworkshop_Click(object sender, EventArgs e)
{
using (SqlConnection conn2 = new SqlConnection(@"Data Source=CIS489_3\WILDLIFE;Initial Catalog=WildLife_Education;Integrated Security=True;"))
{
SqlCommand CmdSql2 = new SqlCommand("INSERT INTO [tblWorkshop] ([WorkshopName], [WorkshopBeginingDate], [WorkshopEndingDate], [WorkshopLocation], [InstructorID])VALUES (@WorkshopName, @WorkshopBeginingDate, @WorkshopEndingDate, @WorkshopLocation, @InstructorID)", conn2);
conn2.Open();
CmdSql2.Parameters.AddWithValue("@WorkshopName", workshopinsertname.Text.ToString());
CmdSql2.Parameters.AddWithValue("@WorkshopBeginingDate", workshopinsertstart.Text.ToString());
CmdSql2.Parameters.AddWithValue("@[WorkshopEndingDate", workshopinsertend.Text.ToString());
CmdSql2.Parameters.AddWithValue("@WorkshopLocation", workshopinsertlocation.Text.ToString());
CmdSql2.Parameters.AddWithValue("@InstructorID", insertinstructorid.SelectedValue.ToString());
CmdSql2.Connection = conn2;
CmdSql2.ExecuteNonQuery();
conn2.Close();
UpdateInsertWorkshop.Update();
this.addnewworkshop_ModalPopupExtender.Hide();
}