User-369506445 posted
hi
please try below code :
Code behind
protected void Page_Load(object sender, EventArgs e)
{
string connectionString = @"Data Source=PC-BAKHTIARI\SQLEXPRESS;Initial Catalog=YourDataBaseName;Integrated Security=True;";
string selectTopics = "select sum(total) from yourtablename";
// Define the ADO.NET Objects
using (SqlConnection con = new SqlConnection(connectionString))
{
SqlCommand topiccmd = new SqlCommand(selectTopics, con);
con.Open();
int numrows = (int)topiccmd.ExecuteScalar();
if (numrows == 0)
{
labal1.Text = numrows.ToString();
}
}
}
in Html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="labal1" runat="server"/>
</div>
</form>
</body>
</html>