Venkata Subbareddy

Venkata Subbareddy

  • 993
  • 774
  • 100k

Additional information: Input string was not in a correct fo

May 26 2015 5:14 AM
 Hi Every one,
 Iam New Software Developer  i write One Logic code But I got Small and simple Error  where iam doing Wrong Find out Me And Modified my  source code in the Below the My Source Code..
 
public void chkStatus_OnCheckedChanged(object sender, EventArgs e)
{
CheckBox chkStatus = (CheckBox)sender;
GridViewRow row = (GridViewRow)chkStatus.NamingContainer;
string UserName = row.Cells[5].ToString();
bool ApproveStatus = chkStatus.Checked;
string constr = @"Data Source=SERVER;Initial Catalog=MuraliIIT;User ID=sa;Password=rits@1234";
string query = "UPDATENewStudentRegistrationForm SET ApproveStstus = @ApprovedStatus WHERE UserName = @UserName";
SqlConnection con = new SqlConnection(constr);
SqlCommand com = new SqlCommand(query, con);
com.Parameters.Add("@ApproveStatus", SqlDbType.Bit).Value = ApproveStatus;
com.Parameters.Add("@UserName", SqlDbType.Char).Value = Convert.ToInt32(UserName);
con.Open();
com.ExecuteNonQuery();
con.Close();
Thanks &Regards,
subbareddy. 

Answers (17)