Thanks for your further description and sorry for my misunderstanding,
I'd like to perform some local tests according to your scenarion, would you
try providing me a simple complete page and code list, also it possible the
complete test database structure would be necessary.
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: AcXmkkn3ShM1FjCrR9uiEzCRTh5HhQ==
| X-WBNR-Posting-Host: 198.54.202.242
| From: "=?Utf-8?B?TWlrZSBLZWxseQ==?=" <Mi*******@community.nospam>
| References: <2F**********************************@microsoft.co m>
<0c**************@TK2MSFTNGXA02.phx.gbl>
| Subject: RE: Optimistic concurrency in custom GridView/SqlDataSource
| Date: Thu, 10 Nov 2005 23:34:03 -0800
| Lines: 154
| Message-ID: <E0**********************************@microsoft.co m>
| 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!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:357293
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hi Steven.
|
| No offence, but I think you missed the point. Thanks for the reply,
though.
|
| The code I posted works. It updates the selected row as expected. It is
when
| I add RowVersion to the code that it I get the error. So, if I change the
| update statement to read "UPDATE SharePartner SET PartnerSiteID =
| @PartnerSiteID, Comments = @Comments, UserName = @userName WHERE
(dbIDSite =
| @dbIDSite) AND (dbIDAntennaOwner = @dbIDAntennaOwner) AND (RowVersion =
| @RowVersion)" then I get the error message indicated. Adding a parameter
| called "RowVersion" takes away the error message, but my update then
fails
| (no records updated).
|
| The part I don't understand is that I don't specify parameters for the
other
| columns, why should I do so for the RowVersion?
|
| "Steven Cheng[MSFT]" wrote:
|
| > Hi Mike,
| >
| > Welcome to ASPNET newsgroup.
| > Regarding on the doing Optimistic concrrency data updating in asp.net
2.0
| > by GridView/SqlDatasource problem, from the code template you provided
the
| > SqlDataSource's update statement is as below:
| >
| > UpdateCommand="UPDATE SharePartner SET PartnerSiteID =
| > @PartnerSiteID, Comments = @Comments, UserName = @userName WHERE
(dbIDSite
| > =
| > @dbIDSite) AND (dbIDAntennaOwner = @dbIDAntennaOwner) ">
| >
| > I haven't found that you use the "RowVersion" field to perform version
| > comparation. Also, since the error message you encountered was:
| > ==========
| > [Must declare the scalar variable "@RowVersion"]
| > error.
| > ==========
| >
| > So I think this maybe the problem. Have you tried add the @RowVersion
| > parameter declaration in the update statement also to see whether it
helps?
| >
| > 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: AcXl1JPHnaT1k9/rQXKswscmduC8lw==
| > | X-WBNR-Posting-Host: 198.54.202.242
| > | From: "=?Utf-8?B?TWlrZSBLZWxseQ==?=" <Mi*******@community.nospam>
| > | Subject: Optimistic concurrency in custom GridView/SqlDataSource
| > | Date: Thu, 10 Nov 2005 00:56:02 -0800
| > | Lines: 64
| > | Message-ID: <2F**********************************@microsoft.co m>
| > | 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!TK2MSFTNGP08.phx.gbl!TK2MSFT NGXA03.phx.gbl
| > | Xref: TK2MSFTNGXA02.phx.gbl
| > microsoft.public.dotnet.framework.aspnet:356949
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| > |
| > | I've chosen to implement the "optimistic concurrency" model in my
| > | application. To assist in that, I've added a ROWVERSION (TIMESTAMP)
| > column to
| > | my main tables. I read the value of the column in my select, remember
it,
| > and
| > | then use it in the update. It works just fine when I have full
control of
| > the
| > | whole process.
| > |
| > | I want to do the same for my GridView/SqlDataSource combinations. I
| > | typically select from a view and update the corresponding table.
| > |
| > | Simply adding a RowVersion column to my GridView and @RowVersion to
the
| > | UpdateCommand results in a [Must declare the scalar variable
| > "@RowVersion"]
| > | error.
| > |
| > | The other columns auto magically get carried over from the select
into
| > the
| > | update, why doesn't the RowVersion?
| > |
| > | Here's the code:
| > |
| > | <asp:GridView ID="GridViewSharePartners"
runat="server"
| > | AutoGenerateColumns="False"
| > | DataKeyNames="dbIDAntennaOwner,dbIDSite"
| > | DataSourceID="SharePartnerList" EmptyDataText="No Partners on record
for
| > this
| > | Site"
| > | Width="549px"
| > | OnRowEditing="GridViewSharePartners_RowEditing" >
| > | <Columns>
| > | <asp:CommandField ShowEditButton="True" />
| > | <asp:BoundField DataField="dbIDSite"
| > | HeaderText="dbIDSite" ReadOnly="True" SortExpression="dbIDSite"
| > | Visible="False" />
| > | <asp:BoundField DataField="dbIDAntennaOwner"
| > | HeaderText="dbIDAntennaOwner" ReadOnly="True"
| > | SortExpression="dbIDAntennaOwner" Visible="False" />
| > | <asp:BoundField DataField="Name"
| > HeaderText="Name"
| > | ReadOnly="True" SortExpression="Name" />
| > | <asp:BoundField DataField="PartnerSiteID"
| > | HeaderText="PartnerSiteID" SortExpression="PartnerSiteID" />
| > | <asp:BoundField DataField="Comments"
| > | HeaderText="Comments" SortExpression="Comments" />
| > | <asp:BoundField DataField="RowVersion"
| > | HeaderText="RowVersion" SortExpression="RowVersion" ReadOnly="True"
| > | Visible="False" />
| > | </Columns>
| > | <HeaderStyle HorizontalAlign="Left" />
| > | </asp:GridView>
| > | <asp:SqlDataSource ID="SharePartnerList"
runat="server"
| > | ConnectionString="<%$ ConnectionStrings:VodacomEMRConnectionString
%>"
| > | SelectCommand="SELECT * FROM vw_SharePartner
WHERE
| > | dbIDSite = @siteID"
| > | UpdateCommand="UPDATE SharePartner SET
PartnerSiteID
| > =
| > | @PartnerSiteID, Comments = @Comments, UserName = @userName WHERE
| > (dbIDSite =
| > | @dbIDSite) AND (dbIDAntennaOwner = @dbIDAntennaOwner) ">
| > | <UpdateParameters>
| > | <asp:SessionParameter Name="userName"
| > | SessionField="UserName" Type="String" />
| > | <asp:QueryStringParameter Name="siteID"
| > | QueryStringField="siteID" Type="Int32" />
| > | </UpdateParameters>
| > | <SelectParameters>
| > | <asp:QueryStringParameter Name="siteID"
| > | QueryStringField="siteID" Type="Int32" />
| > | </SelectParameters>
| > | </asp:SqlDataSource>
| > |
| > |
| >
| >
|