locked
Access database won't update RRS feed

  • Question

  • User-2062395733 posted

    I have an Access database that is bound to a DinamicDetailsView. The problem is that it won't update. When I press the edit button, the edit template is shown, but when I make changes and press update nothing happens. It just returns to the basic template and does not update database. Here is the code so I would be very apreciated if someone could help:

     

     

    1    <%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="unos_o_kemije.aspx.vb" Inherits="unos_o_kemije" title="Untitled Page" %>
    2    
    3    <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    4    </asp:Content>
    5    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    6    
    7    <asp:AccessDataSource ID="AccessDataSource1" runat="server"
    8            ConflictDetection="CompareAllValues" DataFile="~/App_Data/Lab4_nov.mdb"
    9            DeleteCommand="DELETE FROM [Analiza 1] WHERE [Uzorak ID] = ? AND [Datum] = ? AND [Mjesto] = ? AND [Klor] = ? AND [Temperatura] = ? AND [Boja] = ? AND [Mutnoca] = ? AND [pH] = ? AND [KMnO4] = ? AND [Elektrovodljivost] = ? AND [TDS] = ? AND [Kloridi] = ?"
    10           InsertCommand="INSERT INTO [Analiza 1] ([Uzorak ID], [Datum], [Mjesto], [Klor], [Temperatura], [Boja], [Mutnoca], [pH], [KMnO4], [Elektrovodljivost], [TDS], [Kloridi]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
    11           OldValuesParameterFormatString="original_{0}"
    12           SelectCommand="SELECT [Uzorak ID] AS Uzorak_ID, [Datum], [Mjesto], [Klor], [Temperatura], [Boja], [Mutnoca], [pH], [KMnO4], [Elektrovodljivost], [TDS], [Kloridi] FROM [Analiza 1] WHERE (YEAR(Datum) = ?) ORDER BY [Uzorak ID]"
    13           UpdateCommand="UPDATE [Analiza 1] SET Datum = ?, Mjesto = ?, Klor = ?, Temperatura = ?, Boja = ?, Mutnoca = ?, pH = ?, KMnO4 = ?, Elektrovodljivost = ?, TDS = ?, Kloridi = ? WHERE ([Uzorak ID] = ?) AND (Datum = ?) AND (Mjesto = ?) AND (Klor = ?) AND (Temperatura = ?) AND (Boja = ?) AND (Mutnoca = ?) AND (pH = ?) AND (KMnO4 = ?) AND (Elektrovodljivost = ?) AND (TDS = ?) AND (Kloridi = ?)">
    14       <SelectParameters>
    15           <asp:ControlParameter ControlID="DropDownList1" Name="?"
    16               PropertyName="SelectedValue" />
    17       </SelectParameters>
    18       <DeleteParameters>
    19           <asp:Parameter Name="original_Uzorak_ID" Type="Int32" />
    20           <asp:Parameter Name="original_Datum" Type="DateTime" />
    21           <asp:Parameter Name="original_Mjesto" Type="String" />
    22           <asp:Parameter Name="original_Klor" Type="Single" />
    23           <asp:Parameter Name="original_Temperatura" Type="Single" />
    24           <asp:Parameter Name="original_Boja" Type="String" />
    25           <asp:Parameter Name="original_Mutnoca" Type="Single" />
    26           <asp:Parameter Name="original_pH" Type="Single" />
    27           <asp:Parameter Name="original_KMnO4" Type="Single" />
    28           <asp:Parameter Name="original_Elektrovodljivost" Type="Single" />
    29           <asp:Parameter Name="original_TDS" Type="Single" />
    30           <asp:Parameter Name="original_Kloridi" Type="Single" />
    31       </DeleteParameters>
    32       <UpdateParameters>
    33           <asp:Parameter Name="Datum" Type="DateTime" />
    34           <asp:Parameter Name="Mjesto" Type="String" />
    35           <asp:Parameter Name="Klor" Type="Single" />
    36           <asp:Parameter Name="Temperatura" Type="Single" />
    37           <asp:Parameter Name="Boja" Type="String" />
    38           <asp:Parameter Name="Mutnoca" Type="Single" />
    39           <asp:Parameter Name="pH" Type="Single" />
    40           <asp:Parameter Name="KMnO4" Type="Single" />
    41           <asp:Parameter Name="Elektrovodljivost" Type="Single" />
    42           <asp:Parameter Name="TDS" Type="Single" />
    43           <asp:Parameter Name="Kloridi" Type="Single" />
    44           <asp:Parameter Name="original_Uzorak_ID" Type="Int32" />
    45           <asp:Parameter Name="original_Datum" Type="DateTime" />
    46           <asp:Parameter Name="original_Mjesto" Type="String" />
    47           <asp:Parameter Name="original_Klor" Type="Single" />
    48           <asp:Parameter Name="original_Temperatura" Type="Single" />
    49           <asp:Parameter Name="original_Boja" Type="String" />
    50           <asp:Parameter Name="original_Mutnoca" Type="Single" />
    51           <asp:Parameter Name="original_pH" Type="Single" />
    52           <asp:Parameter Name="original_KMnO4" Type="Single" />
    53           <asp:Parameter Name="original_Elektrovodljivost" Type="Single" />
    54           <asp:Parameter Name="original_TDS" Type="Single" />
    55           <asp:Parameter Name="original_Kloridi" Type="Single" />
    56       </UpdateParameters>
    57       <InsertParameters>
    58           <asp:Parameter Name="Uzorak_ID" Type="Int32" />
    59           <asp:Parameter Name="Datum" Type="DateTime" />
    60           <asp:Parameter Name="Mjesto" Type="String" />
    61           <asp:Parameter Name="Klor" Type="Single" />
    62           <asp:Parameter Name="Temperatura" Type="Single" />
    63           <asp:Parameter Name="Boja" Type="String" />
    64           <asp:Parameter Name="Mutnoca" Type="Single" />
    65           <asp:Parameter Name="pH" Type="Single" />
    66           <asp:Parameter Name="KMnO4" Type="Single" />
    67           <asp:Parameter Name="Elektrovodljivost" Type="Single" />
    68           <asp:Parameter Name="TDS" Type="Single" />
    69           <asp:Parameter Name="Kloridi" Type="Single" />
    70       </InsertParameters>
    71       </asp:AccessDataSource>
    72           <asp:AccessDataSource ID="AccessDataSource2" runat="server"
    73           DataFile="~/App_Data/Lab4_nov.mdb"
    74           SelectCommand="SELECT DISTINCT YEAR(Datum) AS Godina FROM [Analiza 1] ORDER BY YEAR(Datum) DESC">
    75       </asp:AccessDataSource>
    76   <asp:DropDownList ID="DropDownList1" runat="server"
    77           DataSourceID="AccessDataSource2" DataTextField="Godina"
    78           DataValueField="Godina" AutoPostBack="True">
    79       </asp:DropDownList>
    80       <br />
    81       <br />
    82       <asp:DynamicDetailsView ID="DynamicDetailsView1" runat="server"
    83           AllowPaging="True" AutoGenerateRows="False" BackColor="White"
    84           BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellPadding="3"
    85           CellSpacing="2" DataKeyNames="Uzorak_ID" DataSourceID="AccessDataSource1"
    86           Font-Names="Verdana" Width="790px">
    87           <PagerSettings Mode="NextPreviousFirstLast" Position="Top"
    88               FirstPageImageUrl="~/Images/first.gif" LastPageImageUrl="~/Images/last.gif"
    89               NextPageImageUrl="~/Images/next.gif"
    90               PreviousPageImageUrl="~/Images/previous.gif" />
    91           <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
    92           <RowStyle BackColor="#EFF3FB" ForeColor="Black" HorizontalAlign="Left" />
    93           <PagerStyle BackColor="#507CD1" ForeColor="White" HorizontalAlign="Center"
    94               Width="200px" Wrap="False" />
    95           <Fields>
    96               <asp:BoundField DataField="Uzorak_ID" HeaderText="Uzorak_ID"
    97                   InsertVisible="False" ReadOnly="True" SortExpression="Uzorak_ID" />
    98               <asp:BoundField DataField="Datum" HeaderText="Datum" SortExpression="Datum" />
    99               <asp:BoundField DataField="Mjesto" HeaderText="Mjesto"
    100                  SortExpression="Mjesto" />
    101              <asp:BoundField DataField="Klor" HeaderText="Klor"
    102                  SortExpression="Klor" />
    103              <asp:BoundField DataField="Temperatura" HeaderText="Temperatura"
    104                  SortExpression="Temperatura" />
    105              <asp:BoundField DataField="Boja" HeaderText="Boja"
    106                  SortExpression="Boja" />
    107              <asp:BoundField DataField="Mutnoca" HeaderText="Mutnoca"
    108                  SortExpression="Mutnoca" />
    109              <asp:BoundField DataField="pH" HeaderText="pH" SortExpression="pH" />
    110              <asp:BoundField DataField="KMnO4" HeaderText="KMnO4"
    111                  SortExpression="KMnO4" />
    112              <asp:BoundField DataField="Elektrovodljivost" HeaderText="Elektrovodljivost"
    113                  SortExpression="Elektrovodljivost" />
    114              <asp:BoundField DataField="TDS" HeaderText="TDS" SortExpression="TDS" />
    115              <asp:BoundField DataField="Kloridi" HeaderText="Kloridi"
    116                  SortExpression="Kloridi" />
    117              <asp:CommandField ButtonType="Button" ShowEditButton="True" />
    118          </Fields>
    119          <HeaderStyle BackColor="#33CCFF" Font-Bold="True" ForeColor="White" />
    120          <EditRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
    121          <AlternatingRowStyle BackColor="White" />
    122      </asp:DynamicDetailsView>
    123  </asp:Content>
    
      
    Wednesday, October 1, 2008 2:03 AM

Answers

  • User-821857111 posted

    Change the UpdateCommand to

    UpdateCommand="UPDATE [Analiza 1] SET Datum = ?, Mjesto = ?, Klor = ?, Temperatura = ?, Boja = ?, Mutnoca = ?, pH = ?, KMnO4 = ?, Elektrovodljivost = ?, TDS = ?, Kloridi = ? WHERE ([Uzorak ID] = ?)"

    Then your UpdateParameters to

           <UpdateParameters>
               <asp:Parameter Name="Datum" Type="DateTime" />
               <asp:Parameter Name="Mjesto" Type="String" />
               <asp:Parameter Name="Klor" Type="Single" />
               <asp:Parameter Name="Temperatura" Type="Single" />
               <asp:Parameter Name="Boja" Type="String" />
               <asp:Parameter Name="Mutnoca" Type="Single" />
               <asp:Parameter Name="pH" Type="Single" />
               <asp:Parameter Name="KMnO4" Type="Single" />
               <asp:Parameter Name="Elektrovodljivost" Type="Single" />
               <asp:Parameter Name="TDS" Type="Single" />
               <asp:Parameter Name="Kloridi" Type="Single" />
               <asp:Parameter Name="Uzorak_ID" Type="Int32" />
           </UpdateParameters>

    Or it might be quicker to reconfigure the AccessDataSource control and don't select the option to use Optimistic Concurrency. 

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 1, 2008 9:02 AM
  • User-2062395733 posted

     I have solved it!!

     

    Mike's step is just the first one. When I did that, it didnt help, but then I changed "Datum = ?" into "Datum = @Datum" and every other parameter from ? to @Parameter... and everithing worked ok.

     

    Thanks Mike!!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 1, 2008 11:33 AM

All replies

  • User-821857111 posted

    Change the UpdateCommand to

    UpdateCommand="UPDATE [Analiza 1] SET Datum = ?, Mjesto = ?, Klor = ?, Temperatura = ?, Boja = ?, Mutnoca = ?, pH = ?, KMnO4 = ?, Elektrovodljivost = ?, TDS = ?, Kloridi = ? WHERE ([Uzorak ID] = ?)"

    Then your UpdateParameters to

           <UpdateParameters>
               <asp:Parameter Name="Datum" Type="DateTime" />
               <asp:Parameter Name="Mjesto" Type="String" />
               <asp:Parameter Name="Klor" Type="Single" />
               <asp:Parameter Name="Temperatura" Type="Single" />
               <asp:Parameter Name="Boja" Type="String" />
               <asp:Parameter Name="Mutnoca" Type="Single" />
               <asp:Parameter Name="pH" Type="Single" />
               <asp:Parameter Name="KMnO4" Type="Single" />
               <asp:Parameter Name="Elektrovodljivost" Type="Single" />
               <asp:Parameter Name="TDS" Type="Single" />
               <asp:Parameter Name="Kloridi" Type="Single" />
               <asp:Parameter Name="Uzorak_ID" Type="Int32" />
           </UpdateParameters>

    Or it might be quicker to reconfigure the AccessDataSource control and don't select the option to use Optimistic Concurrency. 

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 1, 2008 9:02 AM
  • User-2062395733 posted

     I have solved it!!

     

    Mike's step is just the first one. When I did that, it didnt help, but then I changed "Datum = ?" into "Datum = @Datum" and every other parameter from ? to @Parameter... and everithing worked ok.

     

    Thanks Mike!!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 1, 2008 11:33 AM
  • User-821857111 posted

    I changed "Datum = ?" into "Datum = @Datum" and every other parameter from ? to @Parameter... and everithing worked ok.

    Really??  From everything I know, that should have made absolutely no difference whatsoever.
    Wednesday, October 1, 2008 3:19 PM
  • User-2062395733 posted

     I tought so to, but aparently it did.

     

    Thanks

    Thursday, October 2, 2008 1:04 AM