Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > BOOK: Beginning ASP.NET 1.1
|
BOOK: Beginning ASP.NET 1.1
This is the forum to discuss the Wrox book Beginning ASP.NET 1.1 with Visual C#.NET 2003 by Chris Ullman, John Kauffman, Chris Hart, Dave Sussman, Daniel Maharry; ISBN: 9780764557088
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 20th, 2005, 04:35 AM
Registered User
 
Join Date: Feb 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 11 - How to declare ConfigurationSettings

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>

================================================== ===================


 
Old February 23rd, 2005, 10:59 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Do you have Imports System.Configuration in your code, or have System.Configuration as a reference to the project (VS.NET or using \r in vbc compile statement)?

Brian
 
Old February 23rd, 2005, 09:02 PM
Registered User
 
Join Date: Feb 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I already provided both the web.config and default.aspx files on the forum for further review. It appears that I don't have this reference in any of those 2 files. Do you see it anywhere in those two files that I had already submitted? All samples found in the book that I have worked on are error free without ever having any compilation problems regarding this "ConfigurationSettings" error message. This problem begins when I continued with the tutorial sample onward to page 393 that I began to have this error message. Please provide further instructions on how I can edit the web.config or default.aspx or any other file to compile this program error free so that it resembles the tutorial displayed in the book on page 393 of chapter 11. Thank you.



 
Old February 24th, 2005, 08:33 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

No I don't see an imports statement... You could try to use the fully quantified name System.Configuration.ConfigurationSettings. Also, I've had more success with AppSettings.Get("key")

Brian
 
Old February 24th, 2005, 09:21 PM
Registered User
 
Join Date: Feb 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you "bmains". You are correct. To make the program totally error free to my file called "Default.aspx" that I submitted above, I needed to do three things to it.

1. Replace all "CongfigurationSettings" with "System.Configuration.ConfigurationSettings"

2. Remove the "End Sub" above the "</script>"

3. Put a closing parenthesis ---> COUNT ( [Fans].[FanEmail] ) as found in this statement: Dim queryString As String = "SELECT COUNT ( [Fans].[FanEmail] ) FROM [Fans] WHERE ( [Fans].[FanEmail] = @FanEmail )"









Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter-11 Carlw BOOK: Professional SharePoint 2007 Development ISBN: 978-0-470-11756-9 0 October 16th, 2008 02:08 PM
Chapter 11 Moorish BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 11 June 4th, 2008 04:57 PM
chapter 11 figure 11-7 relative positioning pelopito BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 2 November 29th, 2007 06:11 AM
Chapter 11 kappa3 Wrox Book Feedback 0 October 8th, 2003 11:21 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.