Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Here is the following error message
Code:
Code:
Compiler Error Message: CS1009: Unrecognized escape sequence
Source Error:
Line 9: // Create a new connection object
Line 10: SqlConnection conn = new SqlConnection(
Line 11: "Server=OWNER-PC\MSSQLSERVER1;Database=HalloweenCandyStore;" +
Line 12: "Integrated Security=True");
Line 13: // Create a new command object
Here is the actual code that is trying to be used in the webpage:
Code:
<%@ Page Language="C#" %>
<%@ Import Namespace = "System.Data.SqlClient" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
// Create a new connection object
SqlConnection conn = new SqlConnection(
"Server=OWNER-PC\MSSQLSERVER1;Database=HalloweenCandyStore;" +
"Integrated Security=True");
// Create a new command object
SqlCommand comm = new SqlCommand(
"SELECT EmployeeID, Name FROM Employees", conn);
// Open connection
conn.Open();
// Execute the command
SqlDataReader reader = comm.ExecuteReader();
// Read and display the data
while (reader.Read())
{
employeesLabel.Text += reader["Name"] + "<br />";
}
// Close the reader and the connection
reader.Close();
conn.Close();
}
</script>