<asp:DropDownList ID="DDLStatusChange" runat="server" AppendDataBoundItems="true">
<asp:ListItem>-Select-</asp:ListItem>
<asp:ListItem>Just Received</asp:ListItem>
<asp:ListItem>Post Approval</asp:ListItem>
</asp:DropDownList>
<asp:TextBox ID="txtStatusChange" runat="server" Width="200"></asp:TextBox>
<asp:Button ID="btnStatuschange"
runat="server" Text="Status Change" onclick="btnStatuschange_Click" />
C#背后的代码
protected void btnStatuschange_Click(object sender, EventArgs e)
{
using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["OptimaWebCustomerQueryCon"].ConnectionString))
{
conn.Open();
string str = @"Update TblMasterinfo SET AppLoanStatus=@AppLoanStatus Where appid in (@Statuschange)";
using (SqlCommand com = new SqlCommand(str, conn))
{
com.Parameters.AddWithValue("@Statuschange", Convert.ToInt32(txtStatusChange.Text));
com.Parameters.AddWithValue("@AppLoanStatus",DDLStatusChange.SelectedValue);
com.ExecuteNonQuery();
}
conn.Close();
}
}
问题:
我在txtStatusChange中输入这些appid进行更新记录:17110,17147,17524,17736,15906,17268,16440,17241提到当我像17110一样更新单个记录时,更新成功。更新多个记录时发生错误
异常详情: System.FormatException: Input string was not in a correct format.