Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 2.0 and Databases
This is the forum to discuss the Wrox book Beginning ASP.NET 2.0 and Databases by John Kauffman, Bradley Millington; ISBN: 9780471781349
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 2.0 and Databases 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 October 7th, 2006, 10:56 AM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 238
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via MSN to rsearing
Default Chapter 12 Error with binding Calendar?

Is there any particular reason why I am getting:

String or binary data would be truncated.
The statement has been terminated

After doing TIO 1204?

I followed instructions...here is the code for the page:
(Note..there's some extra debugging items--I added another calendar control to see if it was in how calendar was returning the date--doesn't appear so)

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    Protected Sub Calendar2_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs)
        Response.Write(Calendar2.SelectedDate)
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" AutoGenerateRows="False"
            DataKeyNames="emp_id" DataSourceID="DataSource1" Height="50px" Width="296px">
            <Fields>
                <asp:BoundField DataField="emp_id" HeaderText="emp_id" ReadOnly="True" SortExpression="emp_id" />
                <asp:BoundField DataField="minit" HeaderText="minit" SortExpression="minit" />
                <asp:BoundField DataField="lname" HeaderText="lname" SortExpression="lname" />
                <asp:TemplateField HeaderText="hire_date" SortExpression="hire_date">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("hire_date") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <InsertItemTemplate>
                        <asp:Calendar ID="Calendar1" runat="server" SelectedDate='<%# Bind("hire_date") %>'>
                        </asp:Calendar>
                    </InsertItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("hire_date") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="fname" HeaderText="fname" SortExpression="fname" />
                <asp:CommandField ShowInsertButton="True" ShowEditButton="True" />
            </Fields>
        </asp:DetailsView>
        <asp:SqlDataSource ID="DataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MdfPubs %>"
            DeleteCommand="DELETE FROM [employee] WHERE [emp_id] = @emp_id" InsertCommand="INSERT INTO [employee] ([emp_id], [minit], [lname], [hire_date], [fname]) VALUES (@emp_id, @minit, @lname, @hire_date, @fname)"
            SelectCommand="SELECT [emp_id], [minit], [lname], [hire_date], [fname] FROM [employee]"
            UpdateCommand="UPDATE [employee] SET [minit] = @minit, [lname] = @lname, [hire_date] = @hire_date, [fname] = @fname WHERE [emp_id] = @emp_id">
            <DeleteParameters>
                <asp:Parameter Name="emp_id" Type="String" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="minit" Type="String" />
                <asp:Parameter Name="lname" Type="String" />
                <asp:Parameter Name="hire_date" Type="DateTime" />
                <asp:Parameter Name="fname" Type="String" />
                <asp:Parameter Name="emp_id" Type="String" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="emp_id" Type="String" />
                <asp:Parameter Name="minit" Type="String" />
                <asp:Parameter Name="lname" Type="String" />
                <asp:Parameter Name="hire_date" Type="DateTime" />
                <asp:Parameter Name="fname" Type="String" />
            </InsertParameters>
        </asp:SqlDataSource>
        <asp:Calendar ID="Calendar2" runat="server" OnSelectionChanged="Calendar2_SelectionChanged"></asp:Calendar>

    </div>
    </form>
</body>
</html>


 
Old October 7th, 2006, 01:48 PM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 238
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via MSN to rsearing
Default

Well--I found the answer out myself.

To bad the authors don't mention anything about a constraint placed on employee ID's such as:

|A-Z|A-Z|A-Z|1-9|0-9|0-9|0-9|0-9|FM

Where "FM" = F or M

So a valid choice for an employee ID might be:
ABC12345M

Sigh---
Rob

 
Old October 9th, 2006, 07:51 AM
Authorized User
 
Join Date: May 2005
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That is a new constraint to me. If I knew about it I would have mentioned it. For example, at the beginning of chapter 11 (top of page 278) I went to lengths to ensure that if the reader was adding data s/he could stay within the constraints that were known to me. So my apologies for the difficulty and my thanks for your discovery.

I think I see how this happened. I was tryin got make the chapter more interesting by working with tables other than authors. But I don't know why it didn't fail for tech reviewers or me during testing.

- John






Similar Threads
Thread Thread Starter Forum Replies Last Post
Minor textual error chapter 12 bottom of page 406 haguna BOOK: Professional VB 2005 ISBN: 0-7645-7536-8 0 April 16th, 2006 05:48 PM
Chapter 12 code error rsteph7 BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 34 August 18th, 2004 01:53 PM





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