I am novice at .net. I tried a simple sql query with a label control. I've given the code below. When I click 'View in browser' it shows an error message that reads 'There were errors building the project'. But It shows correct results. Please let me know How can I get rid from the annoying error message.
my aspx code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="BasicDB.aspx.cs" Inherits="BasicDB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="DataOutput" runat="server" Text=""></asp:Label>
</div>
</form>
</body>
</html>
using System;
using System.Data.SqlClient;
public partial class BasicDB : System.Web.UI.Page
{
private string dona;
private string ln;
private SqlCommand sqlCmd;
private SqlConnection hookUp;
private SqlDataReader reader;
protected void Page_Load(object sender, EventArgs e)
{
DataOutput.Text = "Supporter's Donations" + "<br/>";
DataOutput.Text += "---------------------------" + "<br/>";
hookUp = new SqlConnection("Server=localhost\\SqlExpress;Database=VoteNow;" +
"Integrated Security=True");
sqlCmd = new SqlCommand("SELECT LastName, DonationAmount FROM Supporters", hookUp);
hookUp.Open();
reader = sqlCmd.ExecuteReader();
while (reader.Read())
{
dona = Convert.ToString(reader["DonationAmount"]);
ln = Convert.ToString(reader["LastName"]);
DataOutput.Text += ln + " donated $" + dona + "<br/>";
}
reader.Close();
hookUp.Close();
}
}