Click here to Skip to main content
15,903,385 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
For some reason when I click edit and make the change I want to make I get the following error. (I configured data source, assigned the data source ID to the grid view and tested by clicking edit - made a simple change from 1 to a 10 - clicked update)

Server Error in '/' Application.

No value given for one or more required parameters.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Data.OleDb.OleDbException: No value given for one or more required parameters.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 


[OleDbException (0x80040e10): No value given for one or more required parameters.]
   System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr) +1007584
   System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +255
   System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +188
   System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +58
   System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +161
   System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +113
   System.Web.UI.WebControls.SqlDataSourceView.ExecuteDbCommand(DbCommand command, DataSourceOperation operation) +386
   System.Web.UI.WebControls.SqlDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) +325
   System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) +92
   System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32 rowIndex, Boolean causesValidation) +907
   System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +704
   System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs e) +95
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
   System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) +123
   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

Version Information: Microsoft .NET Framework Version:2.0.50727.8762; ASP.NET Version:2.0.50727.8762
</pre

What I have tried:

<pre lang="HTML">
<%@ Page Title="" Language="VB" MasterPageFile="~/Admin/admin.master" AutoEventWireup="false" CodeFile="points.aspx.vb" Inherits="Admin_points" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"></asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
  <div>
    <table border="0" width="100%" cellpadding="0" cellspacing="0">
      <tr>
        <td valign="top" style="font-family: Arial; font-size: 9pt;">
          <center>
            <b>Member Profile Administration</b><br />
          </center>
          
          <br />
          
          <asp:GridView ID="GridView1" runat="server" DataSourceID="memberPointsSource" PageSize="1" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="Member" EnableModelValidation="True">
              <Columns>
                  <asp:BoundField DataField="Member" HeaderText="Member" ReadOnly="True" SortExpression="Member" />
                  <asp:BoundField DataField="Points" HeaderText="Points" SortExpression="Points" />
                  <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
              </Columns>
          </asp:GridView>
        </td>
      </tr>
        
    </table>
  </div>
  
  <asp:AccessDataSource ID="memberPointsSource" runat="server" 
        ConflictDetection="CompareAllValues" DataFile="../app_data/SimpleQSet.mdb" 
        DeleteCommand="DELETE FROM [Points] WHERE (([Member] = ?) OR ([Member] IS NULL AND ? IS NULL)) AND (([Points] = ?) OR ([Points] IS NULL AND ? IS NULL))" 
        InsertCommand="INSERT INTO [Points] ([Member], [Points]) VALUES (?, ?)" 
        OldValuesParameterFormatString="original_{0}" 
        SelectCommand="SELECT [Member], [Points] FROM [Points]" 
        UpdateCommand="UPDATE [Points] SET [Points] = ? WHERE (([Member] = ?) OR ([Member] IS NULL AND ? IS NULL)) AND (([Points] = ?) OR ([Points] IS NULL AND ? IS NULL))">
      <DeleteParameters>
          <asp:Parameter Name="original_Member" Type="String" />
          <asp:Parameter Name="original_Points" Type="Int32" />
          <asp:Parameter Name="original_Points" Type="Int32" />
      </DeleteParameters>
      <InsertParameters>
          <asp:Parameter Name="Member" Type="String" />
          <asp:Parameter Name="Points" Type="Int32" />
      </InsertParameters>
      <UpdateParameters>
          <asp:Parameter Name="Points" Type="Int32" />
          <asp:Parameter Name="original_Member" Type="String" />
          <asp:Parameter Name="original_Points" Type="Int32" />
          <asp:Parameter Name="original_Points" Type="Int32" />
      </UpdateParameters>
    </asp:AccessDataSource>


</asp:Content>
Posted
Updated 21-Sep-17 8:20am
Comments
PIEBALDconsult 21-Sep-17 0:27am    
Did you set the values for the parameters?
ZurdoDev 21-Sep-17 8:09am    
You have 5 question marks in your update statement but only 4 update parameters.

1 solution

Based on your queries, you need to specify the original_Member parameter twice for both the UpdateParameters and the DeleteParameters.
<asp:AccessDataSource ID="memberPointsSource" runat="server" 
    ConflictDetection="CompareAllValues" DataFile="../app_data/SimpleQSet.mdb" 
    DeleteCommand="DELETE FROM [Points] WHERE (([Member] = ?) OR ([Member] IS NULL AND ? IS NULL)) AND (([Points] = ?) OR ([Points] IS NULL AND ? IS NULL))" 
    InsertCommand="INSERT INTO [Points] ([Member], [Points]) VALUES (?, ?)" 
    OldValuesParameterFormatString="original_{0}" 
    SelectCommand="SELECT [Member], [Points] FROM [Points]" 
    UpdateCommand="UPDATE [Points] SET [Points] = ? WHERE (([Member] = ?) OR ([Member] IS NULL AND ? IS NULL)) AND (([Points] = ?) OR ([Points] IS NULL AND ? IS NULL))"
>
    <DeleteParameters>
        <asp:Parameter Name="original_Member" Type="String" />
        <asp:Parameter Name="original_Member" Type="String" />
        <asp:Parameter Name="original_Points" Type="Int32" />
        <asp:Parameter Name="original_Points" Type="Int32" />
    </DeleteParameters>
    <InsertParameters>
        <asp:Parameter Name="Member" Type="String" />
        <asp:Parameter Name="Points" Type="Int32" />
    </InsertParameters>
    <UpdateParameters>
        <asp:Parameter Name="Points" Type="Int32" />
        <asp:Parameter Name="original_Member" Type="String" />
        <asp:Parameter Name="original_Member" Type="String" />
        <asp:Parameter Name="original_Points" Type="Int32" />
        <asp:Parameter Name="original_Points" Type="Int32" />
    </UpdateParameters>
</asp:AccessDataSource>

Access uses positional parameters, not named parameters. Therefore, if the query uses the same parameter twice, you need to add it to the parameters collection twice. And the order in which you add the parameters needs to precisely match the order in which the query uses them.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900