I am currently trying to update a database using C#
My issue is that the update query is not working, there is no error produced just reloads the screen and thats it.

My C# is as follows

 void SaveRecords()
        {
            try
            {
                String qry = "Update Ordered_Test Set Ref_Phy = @Ref_Phy, Ord_Phy = @Ord_Phy, Location = @Location, Verified = @Verified, IOS =@IOS, Tech =@Tech, TapeNum =@TapeNum Where Ordered_T = @Ordered_T";
                com.Open();
                SqlCommand con = new SqlCommand(qry, com);

                con.Parameters.AddWithValue("@Ordered_T", Label22.Text.Trim());
                con.Parameters.AddWithValue("@Ref_Phy ", DropDownList2.Text.Trim());
                con.Parameters.AddWithValue("@Ord_Phy ", DropDownList7.Text.Trim());
                con.Parameters.AddWithValue("@Location ", DropDownList1.Text.Trim());
                con.Parameters.AddWithValue("@Verified ", DropDownList6.Text.Trim());
                con.Parameters.AddWithValue("@IOS", IOS.Text.Trim());
                con.Parameters.AddWithValue("@Tech", DropDownList5.Text.Trim());
                con.Parameters.AddWithValue("@TapeNum", TextBox2.Text.Trim());

                con.ExecuteNonQuery();
            }
            finally
            {
                com.Close();
            }
        }

The "SaveRecords" function is getting called by another function which calls multiple other functions on button click

 protected void SaveAll(object sender, EventArgs e)
        {

                signer();
                SaveRecords();

                deletePvalue();
                deleteVvalue();
                deleteAvalue();
                deletevalue();

                AddPNote();
                AddVNote();
                AddAVNote();
                AddImpressionNote();

                ReportReader();
                SearchData();
                ImpressionReader1();
                ImpressionReader2();
                ImpressionReader3();
                ImpressionReader4();
                ImpressionReader5();
                ImpressionReader6();

        }

I have a few thoughts on this.

First, name your controls. That way you know what they are and later you don't find yourself flipping from code to form and back to verify your work.

Second. I bet you are using Visual Studio. Use the power there to break on line 18 of the C# code so you can check all the lines and variables in the block.

Finally, remove the try and see if it blows up with an error. You didn't handle an error so you could be blind to any error in the try block.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.