Hey there, i would like to find out how many records have been modified by my quarry.
I tried a few things, but none would work.
this is my code

SqlConnection conn = new SqlConnection();
            conn.ConnectionString = "server=.\\SQL2008;database=Studentsdb1;Persist Security Info=True;user id=sa;password=1945";
            SqlCommand cmd = new SqlCommand();
            cmd.CommandType = CommandType.Text;
            String SQL = String.Format("UPDATE StudentsTable SET  Account_Amount = '{0}'   WHERE Account_Amount = '{1}'", txtchangeto.Text, txtChangeFrom.Text);
            btnSave.Text = cmd.CommandText.ToString();

            cmd.CommandText = SQL;
            
            cmd.Connection = conn;

            object result = null;
            ConnectionState previousConnectionState = conn.State;
            try
            {
                if (conn.State == ConnectionState.Closed)
                {
                    conn.Open();
                }
                result = cmd.ExecuteScalar();
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (Exception ex)
            {
            }
            finally
            {
                if (previousConnectionState == ConnectionState.Closed)
                {
                    conn.Close();
                }
            }

HOw would i put the amount of records changed into textboxAmountChanged?

txtboxAmountChanged.Text = "i have no clue"....\

Thank you =)

Line 20 should be ExecuteNonQuery, which returns the number of records changed.

Line 20 should be ExecuteNonQuery, which returns the number of records changed.

Thank you. Was very helpful. =)

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.