Browsed by
Category: Programming

Using ExecuteScalar to Populate a Variable in C#

Using ExecuteScalar to Populate a Variable in C#

After many attempts and various and sundry internet searchings, I have finally have properly working code to display the result of a scalar query in tSQL using asp.net C#. I had to add the reference to System.Configuration in Visual Studio. using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.Sql; using System.Data.SqlClient; using System.Configuration; Then I have this code in the PageLoad event of code behind: int addcount; //variable to hold my result string strConnection =…

Read More Read More

Sending a Form to HTML Email Using C# and asp.net 4.0

Sending a Form to HTML Email Using C# and asp.net 4.0

I often find myself needing to set up a form to email page on a website. For whatever reason, I am not able to always use the same code. So my latest code is included here. This code sends an HTML email from an asp.net 4 website using C#. using System; using System.Net; using System.Web.UI.WebControls; using System.Net.Mail; using System.Text; public partial class contact : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { txtFirstName.Focus(); } protected void btnSendMail_Click(object sender, EventArgs e) {…

Read More Read More