Database did not record data inserted. No errors shown. 3 tier design in microsoft visual studios 2010

Unanswered Database did not record data inserted. No errors shown. 3 tier design in microsoft visual studios 2010

  • Saturday, January 19, 2013 11:35 AM
     
     

    This is my INSERT statement into the Database. The Database did not record any data after i clicked the button. No errors are shown. 

            sql = new StringBuilder();
            sql.AppendLine("INSERT INTO PaymentNANO (PaymentID,PaymentType, TotalAmount, DateTime1)");
            sql.AppendLine("VALUES (@PaymentID, @PaymentType, @TotalAmount, @DateTime1)");
            //(PaymentType, TotalAmount, DateTime1)
            try
            {
                conn.Open();
                sqlCmd = new SqlCommand(sql.ToString(), conn);
                sqlCmd.Parameters.AddWithValue("@PaymentID", PaymentID);
                sqlCmd.Parameters.AddWithValue("@PaymentType", PaymentType);
                sqlCmd.Parameters.AddWithValue("@TotalAmount", TotalAmount);
                sqlCmd.Parameters.AddWithValue("@DateTime1", DateTime1);
                result = sqlCmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
            }
            finally
            {
                conn.Close();
            }

            return result;
        }

    Any idea why?



All Replies

  • Saturday, January 19, 2013 8:39 PM
     
     
    Please try to refresh the table  in the Management Studio.

    mysorian

  • Sunday, January 20, 2013 9:20 AM
     
     

    Hello,

    Halve you debug your code to see if it reaches the ExecuteNonQuery method? What to "result" return for a value, -1, 0 or 1?


    Olaf Helper

    Blog Xing