Mega Code Archive

 
Categories / ASP.Net / ADO Database
 

Detecting concurrency errors after updating data (VB)

<%@ 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 SqlDataSource1_Updated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs)         If (e.AffectedRows > 0) Then             Message.Text = "The record has been updated"         Else             Message.Text = "Possible concurrency violation"         End If     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:SqlDataSource ID="SqlDataSource1"                             Runat="server"                             SelectCommand="SELECT * FROM [Customers] WHERE ([CustomerID] = @CustomerID)"                            ConnectionString="<%$ ConnectionStrings:AppConnectionString1 %>"                            DataSourceMode="DataSet"                            ConflictDetection="CompareAllValues"                             OnUpdated="SqlDataSource1_Updated">             <SelectParameters>                 <asp:QueryStringParameter Name="CustomerID"                                            QueryStringField="id"                                            Type="String">                 </asp:QueryStringParameter>             </SelectParameters>         </asp:SqlDataSource>         <asp:Label ID="Message" runat="server" Text="Label"></asp:Label>     </div>     </form> </body> </html>