Insert data in database using Web API in AngularJS

Last Reply 2 months ago By dharmendr

Posted 2 months ago

How to insert data into database based on textbox validations in angularjs?

If the textbox is empty and submit button is entered, the data must not be inserted, it also should throw an error message.

If the textbox contain some value and then submit button is pressed, the data should be inserted.

        public int insertIssueDetails(IssueDetails id)
            SqlConnection myConnection = new SqlConnection();
            myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["ERPConnectionString"].ConnectionString;
            SqlCommand sqlCmd = new SqlCommand();
            DateTime now = DateTime.Now;
            sqlCmd.CommandType = CommandType.StoredProcedure;
            sqlCmd.CommandText = "INSERT_WAREHOUSE_DETAILS";
            sqlCmd.Connection = myConnection;
            sqlCmd.Parameters.AddWithValue("@InvoiceId", id.InvoiceId);
            sqlCmd.Parameters.AddWithValue("@IssueDate", now);
            sqlCmd.Parameters.AddWithValue("@PackingListNo", id.PackingListNo);
            sqlCmd.Parameters.AddWithValue("@DispatchId", id.DispatchId);
            sqlCmd.Parameters.AddWithValue("@IssueQty", id.IssueQty);
            sqlCmd.Parameters.AddWithValue("@CreatedBy", id.CreatedBy);
            int rowInserted = sqlCmd.ExecuteNonQuery();
            return 1;


This question does not have replies that have been liked.