Wrox Programmer Forums
|
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 April 1st, 2004, 01:42 PM
Friend of Wrox
 
Join Date: Apr 2004
Posts: 105
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to RPG SEARCH
Default ch10 wrow united error - please help

Hi there,

I purchased this book and so far so good - until i reached the Wrox United application.

I have followed the code to the letter and debugged all syntax errors only to come across the error - http://www.rpgsearch.co.uk/images/screenerror.jpg this is a screen grab. Does it mean that the dbConnection is left open? I have tried the book for help for about 12 hours and i cant work it out.

I do not know what is going on.... anyone offer any help please? I really want to get this to work as I am trying to build my own shopping cart eventually.



__________________
David Jenkins
 
Old April 1st, 2004, 02:21 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

I think what it says is that there is no connection string defined.
Usually, you either use an hard coded string for the connection, or retrieve it from the Web.config file at run-time.

Can you show us more code? Maybe the problem will then be more obvious....

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old April 1st, 2004, 02:27 PM
Friend of Wrox
 
Join Date: Apr 2004
Posts: 105
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to RPG SEARCH
Default

Yes this the Teams.aspx code....

<%@ Page Language="VB" Debug="true" %>
<script runat="server">

    Sub Page_Load()

        TeamList.DataSource = GetTeams
        TeamList.DataBind()

    End Sub

    Function GetTeams() 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].[TeamID], [Teams].[TeamName], [Teams].[Notes] FROM [Teams]"
            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

</script>
<html>
<head>
</head>
<body>
    <h1>Wrox United
    </h1>
    <h2>Teams
    </h2>
    <p>
        <table>
            <tbody>
                <tr>
                    <td>
                        <asp:DataList id="TeamList" runat="server">
                            <ItemTemplate>
                                <asp:linkbutton text='<%# Container.DataItem("TeamName") %>' CommandArgument='<%# Container.DataItem("TeamID") %>' id="TeamNameLink" style="color:darkred" runat="server" />
                                <br />
                                <asp:Label text='<%# Container.DataItem("Notes") %>' id="teamnotes" runat="server" />
                            </ItemTemplate>
                            <SeparatorTemplate>
                                <br />

                            </SeparatorTemplate>
                        </asp:DataList>
                    </td>
                    <td>
                    </td>
                </tr>
            </tbody>
        </table>
    </p>
</body>
</html>


and this is the web.config code....


<?xml version="1.0" encoding="UTF-8" ?>

<configuration>

    <!--

         The <appSettings> section is used to configure application-specific configuration
         settings. These can be fetched from within apps by calling the
         "ConfigurationSettings.AppSettings(key)" method:

         <appSettings>
            <add key="connectionstring" value="Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=C:/BegASPNET11/WroxUnited/databse/WroxUnited.mdb"/>
         </appSettings>

    -->

    <system.web>

        <!--

            The <sessionState" section is used to configure session state for the application.
            It supports four modes: "Off", "InProc", "StateServer", and "SqlServer". The
            later two modes enable session state to be stored off the web server machine -
            allowing failure redundancy and web farm session state scenarios.

            <sessionState mode="InProc"
                          stateConnectionString="tcpip=127.0.0.1:42424"
                          sqlConnectionString="data source=127.0.0.1;trusted_connection=true"
                          cookieless="false"
                          timeout="20" />

        -->

        <!--

            The <customErrors> section enables configuration of what to do if/when an
            unhandled error occurs during the execution of a request. Specifically, it
            enables developers to configure html error pages to be displayed in place of
            a error stack trace:

            <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
               <error statusCode="403" redirect="NoAccess.htm"/>
               <error statusCode="404" redirect="FileNotFound.htm"/>
            <customErrors>

        -->

        <!--

            The <authentication> section enables configuration of the security authentication
            mode used by ASP.NET to identify an incoming user. It supports a "mode"
            attribute with four valid values: "Windows", "Forms", "Passport" and "None":

            The <forms> section is a sub-section of the <authentication> section,
            and supports configuring the authentication values used when Forms
            authentication is enabled above:

            <authentication mode="Windows">

                    <forms name=".ASPXAUTH"
                           loginUrl="login.aspx"
                           protection="Validation"
                           timeout="999999" />

             </authentication>

        -->


        <!--

            The <authorization> section enables developers/administrators to configure
            whether a user or role has access to a particular page or resource. This is
            accomplished by adding "<allow>" and "<deny>" sub-tags beneath the <authorization>
            section - specifically detailing the users/roles allowed or denied access.

            Note: The "?" character indicates "anonymous" users (ie: non authenticated users).
            The "*" character indicates "all" users.

            <authorization>
               <allow users="joeuser" />
               <allow roles="Admins" />
               <deny users="*" />
            </authorization>

        -->

    </system.web>

</configuration>


cheers for your help

 
Old April 1st, 2004, 02:36 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

What's the name of the folder that holds the database?

This is what you .config says:

C:/BegASPNET11/WroxUnited/databse/WroxUnited.mdb

Shouldn't that be database?

Also, since you're dealing with a Windows path, you can use:

C:\BegASPNET11\WroxUnited\databse\WroxUnited.mdb

Not that it matters much, though.....

Imar



---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old April 2nd, 2004, 05:33 AM
Friend of Wrox
 
Join Date: Apr 2004
Posts: 105
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to RPG SEARCH
Default

Oops - i was meant to put database and i changed it all to \ rather than / just to see if that had an impact. But with no joy its still throwing out the same error. I checked and rechecked the file to make sure the path was correct..

With ASP.NET do you have to set anything up in your pc's ODBC list --- even though the .mdb etension is all ready listed in their. I just read something about that in a old asp tutorial.

Sorry for being such a hoof at this.

cheers for your help its appreciated.

 
Old April 2nd, 2004, 09:44 PM
Friend of Wrox
 
Join Date: Apr 2004
Posts: 105
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to RPG SEARCH
Default



Sorry I feel really stupid now, the error was that the web.config still had the comments brackets in place so it could not see the string to the database!!

Thanks for help and sorry again!

 
Old April 3rd, 2004, 05:01 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Whooops, yeah, I missed that too ;)

Silly how these little things can bring you to a grinding halt sometimes....


Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Wrox United - chapter 14 - error SqlDependency tom_10000001 BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 1 November 10th, 2006 06:22 AM
Wrox United Application Error Help TritonOps BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 3 January 19th, 2006 08:28 AM





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