Try this :
string query = "SELECT SUM(amount) FROM rec_stats WHERE material=0";
SqlCommand cmd = new SqlCommand(query, con);
SqlDataReader reader = null;
int myInt = 0;
try
{
reader = cmd.ExecuteReader();
while (reader.Read())
{
myInt = reader.GetInt32(0);
}
reader.Close();
}
catch (Exception e)
{
MessageBox.Show("! " + e.ToString());
}
txtbx.Text = myInt.ToString();
You can only read the values of a reader while cycling through it, in a while loop.
Hope this helps