I am working on page 389 through 392 of Chapter 11 of ASP.NET 1.1 with
VB.NET 2003. I cannot get the program to resemble page 393 because I am currently receiving this error message after compiling at the end of page 392. Please resolve this problem for me so I can compile ERROR FREE in order to get the program to look like page 393. Thank you.
Compiler Error Message: BC30451: Name 'CongfigurationSettings' is not declared.
Source Error:
Line 263: Dim connectionString As String = CongfigurationSettings.AppSettings("connectionStri ng")
Line 264: Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString )
================================================== ===================
web.config ===>
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<appSettings>
<add key="connectionString" value="Provider=Microsoft.Jet.OLEDB.4.0;Ole DB Services=-4;Data Source=C:\BegASPNet11\Database\WroxUnited.mdb" />
</appSettings>
<system.web>
</system.web>
</configuration>
================================================== ===================
Default.asp ===>
<%@ Page Language="
VB" Debug="true" %>
<script runat="server">
public DateList as New System.Collections.Hashtable()
Sub Page_Load()
' we need to run this each time the page is loaded, so that after a date is selected and the page is posted back,
' the active dates will still be highlighted.
Dim DateReader as System.Data.iDataReader
DateReader = Dates()
While DateReader.Read()
DateList(DateReader("Date")) = DateReader("Date")
End While
'check whether a cookie is present when the page is loaded so that you can change the display
'if the user has already registered
If Not Request.Cookies( "EmailRegister" ) is nothing Then
txtEmailAddress.Visible = False
lblRegister.text = "You have registered for email updates"
btnRegister.visible = False
End If
DateReader.Close()
End Sub
Sub EventCalendar_DayRender(sender As Object, e As DayRenderEventArgs)
If Not DateList(e.day.date) is Nothing then
e.cell.style.add("font-weight", "bold")
e.cell.style.add("font-size", "larger")
e.cell.style.add("border", "3 dotted darkred")
e.cell.style.add("background", "#f0f0f0")
Else
e.cell.style.add("font-weight", "lighter")
e.cell.style.add("color", "DimGray")
End If
End Sub
Function Dates() As System.Data.IDataReader
Dim connectionString As String = ConfigurationSettings.AppSettings("connectionStrin g")
Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString )
Dim queryString As String = "SELECT [Games].[Date], [Games].[GameID] FROM [Games]"
Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
dbConnection.Open
Dim dataReader As System.Data.IDataReader = dbCommand.ExecuteReader(System.Data.CommandBehavio r.CloseConnection)
Return dataReader
End Function
Sub EventCalendar_SelectionChanged(sender As Object, e As EventArgs)
pnlFixtureDetails.Visible = True
MatchesByDateList.DataSource = GamesByDate(EventCalendar.SelectedDate.ToShortDate String)
MatchesByDateList.DataBind()
End Sub
Function Venue(OpponentLocation as string, MatchVenue as integer) as string
If matchvenue = 1 then ' match is at home
return "Wroxville"
else
return opponentlocation
end if
end function
Function GamesByDate(ByVal [date] As Date) As System.Data.IDataReader
Dim connectionString As String = ConfigurationSettings.AppSettings("connectionStrin g")
Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString )
Dim queryString As String = "SELECT [Teams].[TeamName], [Opponents].[OpponentName], "& _
"[Games].[Location], [Opponents].[OpponentLocation] " & _
"FROM [Teams], [Opponents], [Games] "& _
"WHERE (([Opponents].[OpponentID] = [Games].[OpposingTeam]) " & _
"AND ([Teams].[TeamID] = [Games].[WroxTeam]) AND ([Games].[Date] = @Date))"
Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dbParam_date As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
dbParam_date.ParameterName = "@Date"
dbParam_date.Value = [date]
dbParam_date.DbType = System.Data.DbType.DateTime
dbCommand.Parameters.Add(dbParam_date)
dbConnection.Open
Dim dataReader As System.Data.IDataReader = dbCommand.ExecuteReader(System.Data.CommandBehavio r.CloseConnection)
Return dataReader
End Function
Function CheckFanEmailAddress(ByVal fanEmail As String) As Boolean
Dim connectionString As String = ConfigurationSettings.AppSettings("connectionStrin g")
Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString )
Dim queryString As String = "SELECT COUNT ( [Fans].[FanEmail] FROM [Fans] WHERE ( [Fans].[FanEmail] = @FanEmail )"
Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dbParam_fanEmail As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
dbParam_fanEmail.ParameterName = "@FanEmail"
dbParam_fanEmail.Value = fanEmail
dbParam_fanEmail.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_fanEmail)
dbConnection.Open
Dim Result As Integer = 0
Try
Result = dbCommand.ExecuteScalar
Finally
dbConnection.Close
End Try
If Result > 0 Then
Return true
Else
Return false
End if
End Function
Sub btnRegister_Click(sender As Object, e As EventArgs)
Dim FanEmail As String = txtEmailAddress.text
Dim EmailRegisterCookie As New HttpCookie("EmailRegister")
'check whether the email address is already registered.
'If not, we need to register it by calling the AddNewFanEmail() method
If checkFanEmailAddress( FanEmail ) = false Then
AddNewFanEmail( FanEmail )
End if
'email has been registered, so update the display and attempt to set a cookie
txtEmailAddress.Visible = False
lblRegister.text = "You have successfully registered for email updates"
btnRegister.visible = False
EmailRegisterCookie.Value = FanEmail
EmailRegisterCookie.Expires = now.AddSeconds(20)
Response.Cookies.Add( EmailRegisterCookie )
End Sub
Function AddNewFanEmail(ByVal fanEmail As String) As Integer
Dim connectionString As String = CongfigurationSettings.AppSettings("connectionStri ng")
Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString )
Dim queryString As String = "INSERT INTO [Fans] ([FanEmail]) VALUES (@FanEmail)"
Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dbParam_fanEmail As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
dbParam_fanEmail.ParameterName = "@FanEmail"
dbParam_fanEmail.Value = fanEmail
dbParam_fanEmail.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_fanEmail)
Dim rowsAffected As Integer = 0
dbConnection.Open
Try
rowsAffected = dbCommand.ExecuteNonQuery
Finally
dbConnection.Close
End Try
Return rowsAffected
End Function
End Sub
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<h1>Wrox United
</h1>
<table width="800">
<tbody>
<tr>
<td width="580">
<h2>Welcome to the Wrox United Web Site!
</h2>
</td>
<td width="220" border="1">
<asp:Label id="lblRegister" runat="server">Register for email updates </asp:Label>
<asp:textBox id="txtEmailAddress" runat="server"></asp:textBox>
<asp:button id="btnRegister" onclick="btnRegister_Click" runat="server" Width="60px" Text="Register"></asp:button>
<asp:regularExpressionValidator id="validEmail" runat="server" ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ControlToValidate="txtEmailAddress" ErrorMessage="Please enter a valid email address"></asp:regularExpressionValidator>
</td>
</tr>
</tbody>
</table>
<table style="WIDTH: 800px">
<tbody>
<tr>
<td style="VERTICAL-ALIGN: top; WIDTH: 200px">
<p>
<asp:HyperLink id="lnkTeams" runat="server" NavigateUrl="TeamsPage353.aspx">Teams
</asp:HyperLink>
</p>
<p>
<asp:HyperLink id="lnkPlayers" runat="server" NavigateUrl="PlayersWriteUp.aspx">Players
</asp:HyperLink>
</p>
<p>
<asp:HyperLink id="lnkGames" runat="server" NavigateUrl="DefaultWriteUp.aspx">Upcoming Games
</asp:HyperLink>
</p>
<p>
<asp:HyperLink id="lnkResults" runat="server" NavigateUrl="DefaultWriteUp.aspx">Results
</asp:HyperLink>
</p>
</td>
<td style="VERTICAL-ALIGN: top; WIDTH: 350px">
</td>
<td style="VERTICAL-ALIGN: top; WIDTH: 250px">
<asp:Calendar id="EventCalendar" runat="server" OnSelectionChanged="EventCalendar_SelectionChanged " OnDayRender="EventCalendar_DayRender"></asp:Calendar>
<p>
<asp:Panel id="pnlFixtureDetails" runat="server" visible="false">
<asp:Repeater id="MatchesByDateList" runat="server">
<headertemplate>
<span style="width:110px;height:25px">Date: </span> <span style="width:135px;height:25px"> <%# EventCalendar.SelectedDate.ToShortDateString %></span>
<br />
</headertemplate>
<itemtemplate>
<span style="width:110px">Wrox Team</span> <span style="width:135px"> <%# Container.DataItem("TeamName") %></span>
<br />
<span style="width:110px">Opposing Team</span> <span style="width:135px"> <%# Container.DataItem("OpponentName") %></span>
<br />
<span style="width:110px">Venue</span> <span style="width:135px"> <%# venue(Container.DataItem("OpponentLocation"), Container.DataItem("Location")) %></span>
<br />
</itemtemplate>
<separatortemplate>
</separatortemplate>
</asp:Repeater>
</asp:Panel>
</p>
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
================================================== ===================