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!