错误显示为“'@Cmp_DocPath' 附近的语法不正确,如果我使用注释行代码,我得到错误为“此 sqlparametercollection 不包含带有参数名'@Cmp_DocPath'的 sqlparameter”。我如何获取 AsyncFileUpload AJAX 控件的文件名?
protected void BtnCmpApproval_Click(object sender, EventArgs e)
{
SqlConnection SqlCon = new SqlConnection(GetConnectionString());
string query = "INSERT INTO User_Info2 VALUES (@lblCmpUserName,@txtCmpName,
@txtRegCountry,@txtCmpRegNo,@txtCmpEstdate,@txtCmpAddress,@ddlAddrIn)";
try
{
SqlCon.Open();
SqlCommand cmd = new SqlCommand(query, SqlCon);
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@UserName", lblCmpUserName.Text);
cmd.Parameters.AddWithValue("@Cmp_Name", txtCmpName.Text);
cmd.Parameters.AddWithValue("@Commercial_RegNo", txtRegCountry.Text);
cmd.Parameters.AddWithValue("@Comm_Country", txtCmpRegNo.Text);
cmd.Parameters.AddWithValue("@Cmp_EstablishDate", txtCmpEstdate.Text);
//cmd.Parameters.AddWithValue("@Cmp_DocPath", AFU1.FileName);
cmd.Parameters["@Cmp_DocPath"].Value=AFU1.FileName;
cmd.Parameters.AddWithValue("@txtCmpAddress", txtCmpAddress.Text);
cmd.Parameters.AddWithValue("@ddlAddrIn", ddlAddrIn.SelectedItem.Text);
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
finally
{
SqlCon.Close();
}
}