You should refer sql CRUD operation.
This is the simple query.
Select sum(weights) from table where lot_number='"+textbox1.text+"'
Hi for that purpose you can write your code in datalogic as following
SqlConnection conn = new SqlConnection();
conn.ConnectionString = ConfigurationManager.ConnectionStrings["connSpionshopString"].ConnectionString;
string sqlCmd = "Select sum(weights) as TotalWeight from table where lot_number='"+textbox1.text+"';";
SqlCommand cmd = new SqlCommand(sqlCmd, conn);
conn.Open();
object value = cmd.ExecuteScaler();
textbox1.text=value.ToString();
conn.Close();