Bineesh  Viswanath

Bineesh Viswanath

  • NA
  • 1k
  • 780.2k

Data Insertion Error in ASP.NET

Aug 23 2013 1:18 AM
Sir, I getting an error in Save function in ASP.NET

This is funtion I does:-

value in comboBox represent className's classId

divisionName is a new value I Inserting.



And the error arising is:-




The C# code for this function is:-


public void DivisionAdd(divisionInfo infoDivision)
    {
        try
        {
            if (sqlCon.State == ConnectionState.Closed)
            {
                sqlCon.Open();
            }
            SqlCommand c = new SqlCommand("divisionAdd", sqlCon);
            c.CommandType = CommandType.StoredProcedure;
            c.Parameters.Add("divisionName", SqlDbType.VarChar).Value = infoDivision.divisionName;
            c.Parameters.Add("classId", SqlDbType.Decimal).Value = infoDivision.classId;
            int inCount = c.ExecuteNonQuery();
            if (inCount > 0)
            {
                HttpContext.Current.Response.Write("<script>alert('Saved Successfully');</script>");
            }
        }

        catch (Exception)
        {
            throw;
        }
        finally
        {

            sqlCon.Close();
        }
    }

Please help me in this topic.

Answers (5)