Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 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 May 18th, 2009, 05:08 PM
Registered User
 
Join Date: May 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 12: p. 410 Try It Out - DetailsView Control

Hi Imar,

First of all - excellent book, I'm really enjoying learning ASP.NET 3.5!

I've run into a problem with the Try It Out starting on page 410 (Managing Data with the DetailsView Control). I have followed all of the steps (I believe to the letter) four separate times, and every time I run the code I get the error:

"The version of SQL Server in use does not support datatype 'date'."

with the following stack trace:

Code:
[ArgumentException: The version of SQL Server in use does not support datatype 'date'.]
   System.Data.SqlClient.TdsParser.TdsExecuteRPC(_SqlRPC[] rpcArray, Int32 timeout, Boolean inSchema, SqlNotificationRequest notificationRequest, TdsParserStateObject stateObj, Boolean isCommandProc) +4297
   System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +954
   System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +162
   System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +175
   System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +137
   System.Web.UI.WebControls.SqlDataSourceView.ExecuteDbCommand(DbCommand command, DataSourceOperation operation) +386
   System.Web.UI.WebControls.SqlDataSourceView.ExecuteInsert(IDictionary values) +227
   System.Web.UI.DataSourceView.Insert(IDictionary values, DataSourceViewOperationCallback callback) +86
   System.Web.UI.WebControls.DetailsView.HandleInsert(String commandArg, Boolean causesValidation) +274
   System.Web.UI.WebControls.DetailsView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +676
   System.Web.UI.WebControls.DetailsView.OnBubbleEvent(Object source, EventArgs e) +95
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
   System.Web.UI.WebControls.DetailsViewRow.OnBubbleEvent(Object source, EventArgs e) +113
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
   System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +118
   System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +135
   System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
My AddEditReview.aspx page looks like this:

Code:
<%@ Page Language="C#" MasterPageFile="~/MasterPages/ManagementMaster.master" AutoEventWireup="true" CodeFile="AddEditReview.aspx.cs" Inherits="Management_AddEditReview" Title="Planet Wrox - Management - Insert and Update Reviews" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" Runat="Server">
  <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" 
    DataKeyNames="Id" DataSourceID="SqlDataSource1" DefaultMode="Insert" 
    Height="50px" Width="125px">
    <Fields>
      <asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False" 
        ReadOnly="True" SortExpression="Id" />
      <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
      <asp:BoundField DataField="Summary" HeaderText="Summary" 
        SortExpression="Summary" />
      <asp:BoundField DataField="Body" HeaderText="Body" SortExpression="Body" />
      <asp:BoundField DataField="GenreId" HeaderText="GenreId" 
        SortExpression="GenreId" />
      <asp:BoundField DataField="UpdateDateTime" HeaderText="UpdateDateTime" 
        SortExpression="UpdateDateTime" />
      <asp:CheckBoxField DataField="Authorized" HeaderText="Authorized" 
        SortExpression="Authorized" />
      <asp:CommandField ShowEditButton="True" ShowInsertButton="True" />
    </Fields>
  </asp:DetailsView>
  <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
    ConnectionString="<%$ ConnectionStrings:PlanetWroxConnectionString1 %>" 
    DeleteCommand="DELETE FROM [Review] WHERE [Id] = @Id" 
    InsertCommand="INSERT INTO [Review] ([Title], [Summary], [Body], [GenreId], [UpdateDateTime], [Authorized]) VALUES (@Title, @Summary, @Body, @GenreId, @UpdateDateTime, @Authorized)" 
    SelectCommand="SELECT [Id], [Title], [Summary], [Body], [GenreId], [UpdateDateTime], [Authorized] FROM [Review] WHERE ([Id] = @Id)" 
    UpdateCommand="UPDATE [Review] SET [Title] = @Title, [Summary] = @Summary, [Body] = @Body, [GenreId] = @GenreId, [UpdateDateTime] = @UpdateDateTime, [Authorized] = @Authorized WHERE [Id] = @Id">
    <SelectParameters>
      <asp:QueryStringParameter Name="Id" QueryStringField="Id" Type="Int32" />
    </SelectParameters>
    <DeleteParameters>
      <asp:Parameter Name="Id" Type="Int32" />
    </DeleteParameters>
    <UpdateParameters>
      <asp:Parameter Name="Title" Type="String" />
      <asp:Parameter Name="Summary" Type="String" />
      <asp:Parameter Name="Body" Type="String" />
      <asp:Parameter Name="GenreId" Type="Int32" />
      <asp:Parameter DbType="Date" Name="UpdateDateTime" />
      <asp:Parameter Name="Authorized" Type="Boolean" />
      <asp:Parameter Name="Id" Type="Int32" />
    </UpdateParameters>
    <InsertParameters>
      <asp:Parameter Name="Title" Type="String" />
      <asp:Parameter Name="Summary" Type="String" />
      <asp:Parameter Name="Body" Type="String" />
      <asp:Parameter Name="GenreId" Type="Int32" />
      <asp:Parameter DbType="Date" Name="UpdateDateTime" />
      <asp:Parameter Name="Authorized" Type="Boolean" />
    </InsertParameters>
  </asp:SqlDataSource>
</asp:Content>
Any help would be greatly appreciated!
 
Old May 20th, 2009, 07:32 PM
Authorized User
 
Join Date: Jan 2009
Posts: 26
Thanks: 4
Thanked 1 Time in 1 Post
Default

Not sure if this is where you're having your problem, but the data type for the CreateDateTime and the UpdateDateTime fields is supposed to be "datetime" not just date (p375).

In my AddEditReview.aspx I have:
Code:
<asp:Parameter Name="UpdateDateTime" Type="DateTime" />
in the UpdateParameters and InsertParameters section - as opposed to what you have:
Code:
<asp:Parameter DbType="Date" Name="UpdateDateTime" />
It could be there's a mismatch of data type which is causing the error...

Hope this helps...
 
Old May 24th, 2009, 07:22 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Hans,

Good to hear you like the book so much.

The issue you came across is listed in the errata section of the book: http://www.wrox.com/WileyCDA/WroxTit...Cd-ERRATA.html

It's caused by a change in VWD where a DateTime is inferred as a Date. As cbspira indicated, changing Date to DateTime should fix the problem.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with example in chapter 12 (pg 410) peteegan BOOK: Beginning Microsoft Visual Basic 2008 ISBN: 978-0-470-19134-7 1 December 30th, 2008 03:23 PM
Chapter 12: Page 410 - Try it out VeganMan BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 April 20th, 2008 03:44 PM
DetailsView Control Showkkath ASP.NET 1.x and 2.0 Application Design 2 August 21st, 2006 07:49 AM
Problem with updating the detailsview control rakesh225 ASP.NET 2.0 Professional 1 August 2nd, 2006 10:45 AM
Errors on Chapter 12 example(12.8) sonnie ASP.NET 2.0 Professional 2 June 7th, 2006 10:55 AM





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