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 November 18th, 2004, 12:13 PM
Registered User
 
Join Date: Nov 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default ASP.NET 1.1 with VB.NET 2003 chapter 9

I tried the code in this book. (see title)
(Still don't know which one? It's written by Chris Ulman, John Kauffman, Chris Hart, David Sussman.
http://www.wrox.com/WileyCDA/WroxTit...load_code.html)

Page 307 code: I typed in the code from the book.

I get this error: Exception Details: System.Data.OleDb.OleDbException: The field is too small to accept the amount of data you attempted to add. Try inserting or pasting less data.

[OleDbException (0x80040e57): The field is too small to accept the amount of data you attempted to add. Try inserting or pasting less data.]
System.Data.Common.DbDataAdapter.Update(Data Row[] dataRows, DataTableMapping tableMapping) +1644
System.Data.Common.DbDataAdapter.Update(Data Set dataSet, String srcTable) +152
ASP.update_aspx.Page_Load(Object Sender, EventArgs E) in F:\WebMatrix\Ch09\update.aspx:72
System.Web.UI.Control.OnLoad(EventArgs e) +55
System.Web.UI.Control.LoadRecursive() +27
System.Web.UI.Page.ProcessRequestMain() +731

I checked my code... My code should be fine... Is there any typed codes I can download?

Ok... I will paste my codes here as well. It's a bit long.

Thank you: Whoever replied.

<%@ Page Language="VB" Debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<script runat="server">

    Sub Page_Load(Sender As object, E As EventArgs)

        Dim connectionString As String
        Dim queryString As String
        Dim data As New DataSet()
        Dim dbConnection As OleDbConnection
        Dim dataAdapter As OleDbDataAdapter

        ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; " & _
         "Data Source=F:\WebMatrix\Northwind.mdb"

        queryString="SELECT EmployeeID, FirstName, LastName FROM Employees"

        dbConnection = New OledbConnection(connectionString)
        dataAdapter = New OledbDataAdapter(queryString, dbConnection)

        dataAdapter.Fill(data, "Employees")

        DataGrid1.DataSource = data.Tables("Employees")
        DataGrid1.DataBind()



        Dim table As DataTable
        Dim newRow As DataRow

        table = data.Tables("Employees")
        newRow = table.NewRow()
        newRow("FirstName") = "Rogerrrrrrrrrrrrrrrrr"
        newRow("LastName") = "Cccccchennn"
        table.Rows.Add(newRow)

        newRow = table.NewRow()
        newRow("FirstName") = "Sarahhhhhhhhhhhh"
        newRow("LastName") = "Exxxxxxxxxx"
        table.Rows.Add(newRow)

        DataGrid2.DataSource=table
        DataGrid2.DataBind()


        Dim objRow As DataRow
        objRow=table.Rows(3)
        objRow("FirstName")="dkkddkd"
        objRow("LastName")="deledljg"

        DataGrid3.DataSource=table
        DataGrid3.DataBind()

        table.Rows(table.Rows.Count -2).Delete()

        DataGrid4.DataSource=table
        DataGrid4.DataBind()


        'Generate the update commands
        Dim commandBuilder As OleDbCommandBuilder

        commandBuilder = New OleDbCommandBuilder(dataAdapter)
        dataAdapter.UpdateCommand = commandBuilder.GetUpdateCommand()
        dataAdapter.InsertCommand = commandBuilder.GetInsertCommand()
        dataAdapter.DeleteCommand = commandBuilder.GetDeleteCommand()



        'update data store
        dataAdapter.Update(data, "Employees")


        'prove the data has been updated
        queryString = "SELECT EmployeeID, FirstName, LastName FROM Employees"
        dbConnection.Open()
        Dim command As New OleDbCommand(queryString, dbConnection)
        DataGridUpdated.DataSource = _
            command.ExecuteReader(CommandBehavior.CloseConnect ion)
        DataGridUpdated.DataBind()

    End Sub

</script>
<html>
<head>
</head>
<body>
    <table width="100%">
        <tbody>
            <tr>
                <td>
                    Original Data</td>
                <td>
                    Data with new Row</td>
                <td>
                    Data with edited Row</td>
                <td>
                    Data with deleted Row</td>
            </tr>
            <tr>
                <td>
                    <asp:DataGrid id="DataGrid1" runat="server"></asp:DataGrid>
                </td>
                <td>
                    <asp:DataGrid id="DataGrid2" runat="server"></asp:DataGrid>
                </td>
                <td>
                    <asp:DataGrid id="DataGrid3" runat="server"></asp:DataGrid>
                </td>
                <td>
                    <asp:DataGrid id="DataGrid4" runat="server"></asp:DataGrid>
                </td>
            </tr>
        </tbody>
    </table>

    After the update:
    <br />
    <asp:DataGrid id="DataGridUpdated" runat="server"></asp:DataGrid>
</body>
</html>
 
Old November 18th, 2004, 01:50 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

What are the sizes of the columns in the DB?

 
Old November 18th, 2004, 04:12 PM
Registered User
 
Join Date: Nov 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for your reply stu9820.

sizes of the columns? you mean rows, or the width of the columns? I thought rows can be added automatically. Anyway, I checked it's 9 rows, and the 4th row has been updated. But there's no 10th row there which it should be.

Furthermore, I downloaded this database from this web site. And I followed the instruction. Theoretically, it should work. or the book has a glitch here?

Thank you

Roger

 
Old November 18th, 2004, 04:17 PM
Registered User
 
Join Date: Nov 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

One more thing: what does DB stand for? As well as Ole?






Similar Threads
Thread Thread Starter Forum Replies Last Post
Beginning VB.NET 2003 Chapter 16 siegmeister BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 7 October 8th, 2012 11:29 AM
Beginning VB.Net 2003 - Chapter 16 dougmcgee BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 7 July 15th, 2005 04:42 AM
ASP.NET 1.1 with VB.NET 2003 chapter 1 subroger Wrox Book Feedback 2 November 11th, 2004 12:52 PM
Chapter 5 and 6 of Beg. VB.Net 2003 Koga BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 1 October 9th, 2004 05:02 AM





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