private void button1_Click(object sender, EventArgs e)
{
string costring = connection();
string MyQuery = "select SUM(balance) from dbo.KmtAccounts where registernumber='" + txtRegNo.Text + "'";
SqlConnection conn = new SqlConnection(costring);
SqlCommand cmd = new SqlCommand(MyQuery, conn);
conn.Open();
SqlDataReader reader = cmd.ExecuteReader();
lblResult.Text =
}
private void button1_Click(object sender, EventArgs e) { string costring = connection(); string MyQuery =
Share
In this instance I would probably recomend that you use SqlCommand.ExecuteScalar Method seeing as you have a single value that is returned.
Then you would probably look at Convert.ToString Method when you wish to assign it to the label text property.
Or if you wish to have it formatted, you could look at using Convert.ToDouble Method and then Double.ToString Method to format it if you wish.