how to use executescalar........
i m using this code.
string connstr = @"Server=.\SQLEXPRESS ;Initial Catalog=ABJDATABASE;Integrated Security=True; Max Pool Size=100";
string query = "SELECT SUM(txtWeight) AS txtWeight FROM personalData";
SqlConnection conn = new SqlConnection(connstr);
conn.Open();
SqlCommand myCommand = new SqlCommand(query, conn);
txtTotalWeight.Text = (string)myCommand.ExecuteScalar();
conn.Close();
it gives a error
Unable to cast object of type 'System.Double' to type 'System.String'.