此 SqlParameterCollection 中未包含带有 ParameterName“@courceDepart”的 SqlParameter。
protectedvoidbtnAdd_Click(objectsender,EventArgse){SqlConnectionconn=newSqlConnection...
protected void btnAdd_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);//创建连接对象
SqlCommand insertCmd = new SqlCommand("insert into Cource(courceID,teaID,courceName,courceDepart,courceTime,courceAddress,courceInfo) values(@courceID,@teaID,@courceName,@courceDepart,@courceTime,@courceAddress,@courceInfo)", conn);
insertCmd.Parameters.Add("@courceID", SqlDbType.VarChar, 20);//设置参数
insertCmd.Parameters.Add("@teaID", SqlDbType.VarChar, 20);
insertCmd.Parameters.Add("@courceName", SqlDbType.VarChar, 100);
insertCmd.Parameters.Add("@courceTime", SqlDbType.VarChar, 20);
insertCmd.Parameters.Add("@courceAddress", SqlDbType.VarChar, 50);
insertCmd.Parameters.Add("@courceInfo", SqlDbType.Text);
insertCmd.Parameters["@courceID"].Value = txtCourceID.Text; //为参数赋值
insertCmd.Parameters["@teaID"].Value = ddlTeacherName.SelectedValue;
insertCmd.Parameters["@courceName"].Value = txtCourceName.Text;
insertCmd.Parameters["@courceDepart"].Value = int.Parse(ddlDepart.SelectedValue);
insertCmd.Parameters["@courceTime"].Value = txtTime.Text;
insertCmd.Parameters["@courceAddress"].Value = txtAddress.Text;
insertCmd.Parameters["@courceInfo"].Value = txtCourceInformation.Text;
错误提示:此 SqlParameterCollection 中未包含带有 ParameterName“@courceDepart”的 SqlParameter。可我就是找不出哪里错啊!!! 展开
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);//创建连接对象
SqlCommand insertCmd = new SqlCommand("insert into Cource(courceID,teaID,courceName,courceDepart,courceTime,courceAddress,courceInfo) values(@courceID,@teaID,@courceName,@courceDepart,@courceTime,@courceAddress,@courceInfo)", conn);
insertCmd.Parameters.Add("@courceID", SqlDbType.VarChar, 20);//设置参数
insertCmd.Parameters.Add("@teaID", SqlDbType.VarChar, 20);
insertCmd.Parameters.Add("@courceName", SqlDbType.VarChar, 100);
insertCmd.Parameters.Add("@courceTime", SqlDbType.VarChar, 20);
insertCmd.Parameters.Add("@courceAddress", SqlDbType.VarChar, 50);
insertCmd.Parameters.Add("@courceInfo", SqlDbType.Text);
insertCmd.Parameters["@courceID"].Value = txtCourceID.Text; //为参数赋值
insertCmd.Parameters["@teaID"].Value = ddlTeacherName.SelectedValue;
insertCmd.Parameters["@courceName"].Value = txtCourceName.Text;
insertCmd.Parameters["@courceDepart"].Value = int.Parse(ddlDepart.SelectedValue);
insertCmd.Parameters["@courceTime"].Value = txtTime.Text;
insertCmd.Parameters["@courceAddress"].Value = txtAddress.Text;
insertCmd.Parameters["@courceInfo"].Value = txtCourceInformation.Text;
错误提示:此 SqlParameterCollection 中未包含带有 ParameterName“@courceDepart”的 SqlParameter。可我就是找不出哪里错啊!!! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询