Hello Steven,
Thats a pretty poor show given the purpose of the timestamp. How it got
this far i'll never know, all i can say is you guys need to get some
application development done using microsoft technologies to see how the
real world copes. Sure you have your
ConflictDetection="CompareAllValues"
but come on - the sqlserver timestamp has for years on end been the way of
cicumventing that check. If it changed then the row changed. The only
reasons to use the full compareallvalues option would be to do the column
level conflict detection or to write more generic statements that would work
with more than one provider.
ok, so i've been using the beta .net 2 for some time now and now have the
final release. i waited for the finale to use this grid and sqldatasource
stuff thinking that by then you'd have it all ironed and the world would
have corrected you via the developer feedback site. i toyed with the
objectdatasource and the juries out on that one, reflection and all that
jazz. i kind of get the idea, your master plan, currently treading water in
the application developer domain, hoping soon to swim the 50m, but really
daft mistakes like this make us all sink.
silly ommisions that make the sqldatasource ridiculously code verbose defeat
the whole purpose of it. having to manually implement and workaround basic
concepts like timestamps really is a thumper. man i might as well just lay
down and let you roll a truck over me for all the good it does. this is .net
v2. sure you overhauled it - but am i gonna have to wait till 2.1 now to
get something decent? by then my applications will be so full of
workarounds it'll take a rewrite to sort it all out.
Cheers
Jason
"Steven Cheng[MSFT]" <stcheng@online.microsoft.com> wrote in message
news:xwOFVNq6FHA.392@TK2MSFTNGXA02.phx.gbl...[color=blue]
> Hi Mike,
>
> I've just made some testing according to the code and database you
> provided. Seems that the problem is somewhat related to the timestamp
> sqltype's mapping in the .NET SqlDataSource control and GridView. From my
> test, the SqlDataSource will mapp the timestamp column to an "Object" type
> in DataSource's parameter, however, this type seem not able to persisted
> the timestamp value. So when updating ,the value can not be actually
> passed
> back to the SqlDataSource ... So I'm thinking that we may need to
> define
> a custom template fields to store this timestamp value and manually adding
> it into the updating parameter's collection through the GridView's
> updating
> event...
>
> Steven Cheng
> Microsoft Online Support
>
> Get Secure!
www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
>
>
>
> --------------------
> | X-Tomcat-ID: 299505317
> | References: <2F74A2BD-D043-40A7-A32B-B0837F230DC1@microsoft.com>
> <0ca7wim5FHA.2672@TK2MSFTNGXA02.phx.gbl>
> <E09713C5-4B5F-4B04-AD83-314BC41A06D1@microsoft.com>
> <Hmc2A$M6FHA.1236@TK2MSFTNGXA02.phx.gbl>
> <7DAB09DC-C53E-41EB-8A67-EE1C2335038D@microsoft.com>
> | MIME-Version: 1.0
> | Content-Type: text/plain
> | Content-Transfer-Encoding: 7bit
> | From:
stcheng@online.microsoft.com (Steven Cheng[MSFT])
> | Organization: Microsoft
> | Date: Tue, 15 Nov 2005 14:22:29 GMT
> | Subject: RE: Optimistic concurrency in custom GridView/SqlDataSource
> | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
> | Message-ID: <F90qGAf6FHA.1240@TK2MSFTNGXA02.phx.gbl>
> | Newsgroups: microsoft.public.dotnet.framework.aspnet
> | Lines: 118
> | Path: TK2MSFTNGXA02.phx.gbl
> | Xref: TK2MSFTNGXA02.phx.gbl
> microsoft.public.dotnet.framework.aspnet:358233
> | NNTP-Posting-Host: tomcatimport2.phx.gbl 10.201.218.182
> |
> | Thanks for your followup and the code, I'll make some tests and update
> you
> | soon.
> |
> | Thanks,
> |
> | Steven Cheng
> | Microsoft Online Support
> |
> | Get Secure!
www.microsoft.com/security
> | (This posting is provided "AS IS", with no warranties, and confers no
> | rights.)
> | --------------------
> | | Thread-Topic: Optimistic concurrency in custom GridView/SqlDataSource
> | | thread-index: AcXo/W8zDm9eKpv+TnG/WBTPf+bdaw==
> | | X-WBNR-Posting-Host: 198.54.202.242
> | | From: "=?Utf-8?B?TWlrZSBLZWxseQ==?=" <MikeKelly@community.nospam>
> | | References: <2F74A2BD-D043-40A7-A32B-B0837F230DC1@microsoft.com>
> | <0ca7wim5FHA.2672@TK2MSFTNGXA02.phx.gbl>
> | <E09713C5-4B5F-4B04-AD83-314BC41A06D1@microsoft.com>
> | <Hmc2A$M6FHA.1236@TK2MSFTNGXA02.phx.gbl>
> | | Subject: RE: Optimistic concurrency in custom GridView/SqlDataSource
> | | Date: Mon, 14 Nov 2005 01:26:04 -0800
> | | Lines: 76
> | | Message-ID: <7DAB09DC-C53E-41EB-8A67-EE1C2335038D@microsoft.com>
> | | MIME-Version: 1.0
> | | Content-Type: text/plain;
> | | charset="Utf-8"
> | | Content-Transfer-Encoding: 7bit
> | | X-Newsreader: Microsoft CDO for Windows 2000
> | | Content-Class: urn:content-classes:message
> | | Importance: normal
> | | Priority: normal
> | | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
> | | Newsgroups: microsoft.public.dotnet.framework.aspnet
> | | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
> | | Path:
> TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSF TNGXA03.phx.gbl
> | | Xref: TK2MSFTNGXA02.phx.gbl
> | microsoft.public.dotnet.framework.aspnet:357860
> | | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
> | |
> | | Here is a simple mockup page that models the problem.
> | |
> | | <%@ Page Language="C#" AutoEventWireup="true"
> CodeFile="Default.aspx.cs"
> | | Inherits="_Default" %>
> | |
> | | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> | | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> | |
> | | <html xmlns="http://www.w3.org/1999/xhtml" >
> | | <head runat="server">
> | | <title>Untitled Page</title>
> | | </head>
> | | <body>
> | | <form id="form1" runat="server">
> | | <div>
> | | <asp:GridView ID="GridView1" runat="server"
> | | AutoGenerateColumns="False" DataKeyNames="id"
> | | DataSourceID="SqlDataSourceOptimistic">
> | | <Columns>
> | | <asp:CommandField ShowEditButton="True" />
> | | <asp:BoundField DataField="id" HeaderText="id"
> | | InsertVisible="False" ReadOnly="True"
> | | SortExpression="id" />
> | | <asp:BoundField DataField="name" HeaderText="name"
> | | SortExpression="name" />
> | | </Columns>
> | | </asp:GridView>
> | | <asp:SqlDataSource ID="SqlDataSourceOptimistic" runat="server"
> | | ConflictDetection="CompareAllValues"
> | | ConnectionString="<%$
> ConnectionStrings:PlayConnectionString
> | %>"
> | | DeleteCommand="DELETE FROM [Optimistic] WHERE [id] = @original_id AND
> | [name]
> | | = @original_name AND [rowversion] = @original_rowversion"
> | | InsertCommand="INSERT INTO [Optimistic] ([name],
> | [rowversion])
> | | VALUES (@name, @rowversion)"
> | | OldValuesParameterFormatString="original_{0}"
> | | SelectCommand="SELECT * FROM [Optimistic]"
> | | UpdateCommand="UPDATE [Optimistic] SET [name] = @name,
> | | [rowversion] = @rowversion WHERE [id] = @original_id AND [name] =
> | | @original_name AND [rowversion] = @original_rowversion">
> | | <DeleteParameters>
> | | <asp:Parameter Name="original_id" Type="Int32" />
> | | <asp:Parameter Name="original_name" Type="String" />
> | | <asp:Parameter Name="original_rowversion"
> Type="Object"
> />
> | | </DeleteParameters>
> | | <UpdateParameters>
> | | <asp:Parameter Name="name" Type="String" />
> | | <asp:Parameter Name="rowversion" Type="Object" />
> | | <asp:Parameter Name="original_id" Type="Int32" />
> | | <asp:Parameter Name="original_name" Type="String" />
> | | <asp:Parameter Name="original_rowversion"
> Type="Object"
> />
> | | </UpdateParameters>
> | | <InsertParameters>
> | | <asp:Parameter Name="name" Type="String" />
> | | <asp:Parameter Name="rowversion" Type="Object" />
> | | </InsertParameters>
> | | </asp:SqlDataSource>
> | |
> | | </div>
> | | </form>
> | | </body>
> | | </html>
> | |
> | | Here's the corresponding table:
> | |
> | | CREATE TABLE [dbo].[Optimistic](
> | | [id] [int] IDENTITY(1,1) NOT NULL,
> | | [name] [varchar](50) NULL,
> | | [rowversion] [timestamp] NOT NULL,
> | | CONSTRAINT [PK_Optimistic] PRIMARY KEY CLUSTERED
> | | (
> | | [id] ASC
> | | )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
> | | ) ON [PRIMARY]
> | |
> | | GO
> | |
> | |
> |
> |
>[/color]