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 July 3rd, 2005, 04:32 PM
Registered User
 
Join Date: Jul 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default (C#) Ch09 errata EditingData.aspx: not working

(C#) Ch09 errata EditingData.aspx: not working

Hey all,
I'm working through the Beginning ASP.NET 1.1 vis C# 03 book, and things are peachy until Chapter 9, Try It Out code called "EditingData.aspx." Then troubles. There is errata on the site, yes with changes for the end of the script: the only p.295 errata listed at <http://www.wrox.com/WileyCDA/WroxTitle/productCd-0764557084,descCd-view_errata.html>.

Updating the code with the errata does nothing but change the error message. Here's the final script (errata noted):


void Page_Load(Object sender, EventArgs e) {

    string connectionString;
    string queryString;
    DataSet data = new DataSet();
    OleDbConnection dbConnection;
    OleDbDataAdapter dataAdapter;

    connectionString = "Provider=Microsoft.Jet.OLEDB.4.0; " +
            "Data Source=C:\\BegASPNet11\\data\\Northwind.mdb";
            queryString = "SELECT FirstName, LastName FROM Employees";

    dbConnection = new OleDbConnection(connectionString);
    dataAdapter = new OleDbDataAdapter(queryString, dbConnection);

    dataAdapter.Fill(data, "Employees");

    DataGrid1.DataSource = data;
    DataGrid1.DataBind();

    // ---------------------------------------------------------
    // Marker 1
    DataTable table;
    DataRow newRow;

    table = data.Tables["Employees"];
    newRow = table.NewRow();
    newRow["FirstName"] = "Norman";
    newRow["LastName"] = "Blake";
    table.Rows.Add(newRow);

    // bind the second grid to the new data
    DataGrid2.DataSource = table;
    DataGrid2.DataBind();

    // ---------------------------------------------------------
    // Marker 2
    DataRow[] selectedRows;

    //----- ERRATA START -----
    // find the row to change
    selectedRows = table.Select("FirstName='Margaret' AND LastName='Peacock'");
    if (selectedRows.Length > 0)
    {
    selectedRows(0).item("FirstName") = "John";
    selectedRows(0).item("LastName") = "Hartford";
    }

    // bind the data grid to the new data
    DataGrid3.DataSource = table;
    DataGrid3.DataBind();
    //----- END ERRATA -----

    // ---------------------------------------------------------
    // Marker 3
    // The Rows collection is 0 indexed, therefore
    // this deletes the sixth row
    table.Rows[5].Delete();

    // bind the fourth grid to the new data
    DataGrid4.DataSource = table;
    DataGrid4.DataBind();
    }



And here's the brief compiler error message:


Compiler Error Message: CS0118: 'selectedRows' denotes a 'variable' where a 'method' was expected

Source Error:

Line 47: if (selectedRows.Length > 0)
Line 48: {
Line 49: selectedRows(0).item("FirstName") = "John";
Line 50: selectedRows(0).item("LastName") = "Hartford";
Line 51: }


This gotta be me, right? I inserted the fixed code incorrectly? I know that there is a proviso before the code, stating that since the code should alter the databse, the dbase will have to be reset. But since I've never gotten the code to work, I figured that shouldn't be an issue (plus, I can't make the reset code work either).

Thanks in advance for anyone's time

Matt







Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with ch09 "Creating a filter" example. [email protected] BOOK: Beginning Ruby on Rails 2 March 26th, 2007 11:06 AM
aspx file not working kefi2927 General .NET 2 January 7th, 2005 06:46 AM
ShowArchive.aspx is not working groupmatch BOOK: ASP.NET Website Programming Problem-Design-Solution 2 October 22nd, 2004 10:44 PM
Ch13 EditingData.aspx mahir BOOK: Beginning ASP.NET 1.0 8 April 28th, 2004 03:25 AM
my aspx.net first page is not working Raz Muhammad .NET Web Services 2 March 7th, 2004 09:06 AM





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