[DetailsView, deleting rows]No value given for one or more required parameters

Rate It (1)

Last post 07-10-2007 11:37 AM by szmitek. 2 replies.

Sort Posts:

  • Huh? [:^)] [DetailsView, deleting rows]No value given for one or more required parameters

    07-10-2007, 10:25 AM
    • Loading...
    • szmitek
    • Joined on 03-03-2007, 7:22 PM
    • Chotomów, Poland
    • Posts 59

    How to delete a row in a simple auto-generated DetailsView showing content of a table? I created auto-generated DetailsView in this way:

    <asp:DetailsView ID="news_table" runat="server" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2" DataSourceID="news_source" AllowPaging="True">

    <Fields>

    <asp:CommandField ShowEditButton="True" EditText="Edytuj" UpdateText="Aktualizuj" CancelText="Anuluj" ShowDeleteButton="True" DeleteText="Usuń nowinkę" NewText="Nowa nowinka" InsertText="Dodaj" ShowInsertButton="True" />

    </Fields>
    </asp:DetailsView>

    <asp:AccessDataSource ID="news_source" runat="server" DataFile="~/App_Data/data.mdb"

    SelectCommand="SELECT pubDate,description_pl,description_en,title_pl,title_en,link_pl,link_en,category_pl,category_en,place,en From news"

    UpdateCommand="UPDATE news Set pubDate=@pubDate,description_pl=@description_pl,description_en=@description_en,title_pl=@title_pl,title_en=@title_en,link_pl=@link_pl,link_en=@link_en,category_pl=@category_pl,category_en=@category_en,place=@place,en=@en" DeleteCommand="DELETE FROM news WHERE description_pl = @description_pl" InsertCommand="INSERT Into news (pubDate,description_pl,description_en,title_pl,title_en,link_pl,link_en,category_pl,category_en,place,en) Values (@pubDate,@description_pl,@description_en,@title_pl,@title_en,@link_pl,@link_en,@category_pl,@category_en,@place,@en)"><DeleteParameters><asp:FormParameter FormField="news_table$ctl02" Name="description_pl"/></DeleteParameters></asp:AccessDataSource>

    After clicking "Usuń nowinkę" (deleting button), the error occurs "System.Data.OleDb.OleDbException: No value given for one or more required parameters". Earlier I tried without parameter, with ControlParameter, with Parameter (Name="description_pl") and this causes the same error. Data is inserted, updated and selected correctly, only deleting causes error. When I used simple DeleteCommand "Delete From news", whole content of the table was being deleted. Could you help me? I am asking for help politely.

  • Re: [DetailsView, deleting rows]No value given for one or more required parameters

    07-10-2007, 10:41 AM
    Answer
    • Loading...
    • ecbruck
    • Joined on 12-30-2005, 7:39 PM
    • Des Moines, IA
    • Posts 7,603
    • Moderator
      TrustedFriends-MVPs

    Use the standard Parameter control with the name set to 'description_pl'. Then, add this same field name to the DetailsView.DataKeyNames property declaratively within your ASPX. Hopefully this should solve your problem.

    Thanks, Ed

    Microsoft MVP - ASP/ASP.NET

    protected void Post_Answered(object sender, EventArgs e) { if (this.MarkAsAnswered != null) { this.MarkAsAnswered(this, EventArgs.Empty); } }
  • Thank you.

    07-10-2007, 11:37 AM
    • Loading...
    • szmitek
    • Joined on 03-03-2007, 7:22 PM
    • Chotomów, Poland
    • Posts 59

    Thank you. I inserted 'DataKeyNames="description_pl"' to DetailsView.

Page 1 of 1 (3 items)
Microsoft Communities
Page view counter