Aucune valeur donnée pour un ou plusieurs des paramètres requis.
Description :
Une exception non gérée s'est produite au moment de l'exécution de la requête Web actuelle. Contrôlez la trace de la pile pour plus d'informations sur l'erreur et son origine dans le code.
Détails de l'exception: System.Data.OleDb.OleDbException: Aucune valeur donnée pour un ou plusieurs des paramètres requis.
Erreur source:
Une exception non gérée s'est produite lors de l'exécution de la requête Web actuelle. Les informations relatives à l'origine et l'emplacement de l'exception peuvent être identifiées en utilisant la trace de la pile d'exception ci-dessous.
Are you sure, because the error (translated in English : no value given for one or more required parameters) is telling that you didn't specify any parameters in the Insert- and Update-Parameter collections. Alss, in your update statement, you don't need
to update the Key field (Id_compte). Assuming this field is a Autonumber Field, you don't need to include this field in the insertcommand.
<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="~/App_Data/baseCompte.accdb"
SelectCommand="SELECT [id_compte], [titulaire], [solde] FROM [Compte] ORDER BY [id_compte]"
InsertCommand="INSERT INTO [Compte]([titulaire], [solde]) VALUES (@titulaire, @solde)"
DeleteCommand="DELETE FROM [Compte] WHERE [id_compte] = @id_compte"
UpdateCommand="UPDATE [Compte] SET [titulaire] = @titulaire, [solde] = @solde WHERE [id_compte] = @id_compte"> <InsertParameters> <asp:Parameter Name="titulaire" /> <asp:Parameter Name="solde" /> </InsertParameters> <UpdateParameters> <asp:Parameter Name="titulaire" /> <asp:Parameter Name="solde" /> <asp:Parameter Name="id_compte" /> </UpdateParameters>
<DeleteParameters>
<asp:Parameter Name="id_compte" />
</DeleteParameters>
</asp:AccessDataSource>
Note that the order of the parameters in the collection should match the order the parameters (first) appear in the command.
Finally, in order to make the UPDATE and DELETE work, you need to specify the
DataKeyNames Property of the DetailsView
karim88
0 Points
6 Posts
problems datasourceAccess & detailsview
May 01, 2012 07:12 AM|LINK
hello
I have a problem with my detailview
the button insert and update work well
but delete don't works
I don't find the problem
below my code generated by visualstudio :
<asp:Panel ID="Panel2" runat="server" style="float:left;margin-right:20px;"
GroupingText="Table des enregistrements : " Height="175px" Width="325px" >
<asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True"
AutoGenerateRows="False" DataSourceID="AccessDataSource1" Height="50px"
Width="298px" onpageindexchanging="DetailsView1_PageIndexChanging"
EnablePagingCallbacks="True">
<Fields>
<asp:BoundField DataField="id_compte" HeaderText="id_compte"
SortExpression="id_compte" />
<asp:BoundField DataField="titulaire" HeaderText="titulaire"
SortExpression="titulaire" />
<asp:BoundField DataField="solde" HeaderText="solde" SortExpression="solde" />
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True"
ShowInsertButton="True" />
</Fields>
</asp:DetailsView>
<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="~/App_Data/baseCompte.accdb"
SelectCommand="SELECT [id_compte], [titulaire], [solde] FROM [Compte] ORDER BY [id_compte]"
InsertCommand="INSERT INTO [Compte]([id_compte],[titulaire], [solde]) VALUES (@id_compte, @titulaire, @solde)"
DeleteCommand="DELETE FROM [Compte] WHERE [id_compte] = ?"
UpdateCommand="UPDATE [Compte] SET [id_compte] = @id_compte,[titulaire] = @titulaire, [solde] = @solde
WHERE [id_compte] = @id_compte">
<DeleteParameters>
<asp:Parameter Name="id_compte" Type="Int32" />
</DeleteParameters>
</asp:AccessDataSource>
</asp:Panel>
and the error is :
Aucune valeur donnée pour un ou plusieurs des paramètres requis.
Description : Une exception non gérée s'est produite au moment de l'exécution de la requête Web actuelle. Contrôlez la trace de la pile pour plus d'informations sur l'erreur et son origine dans le code.
Détails de l'exception: System.Data.OleDb.OleDbException: Aucune valeur donnée pour un ou plusieurs des paramètres requis.
Erreur source:
Trace de la pile:
do you have any idea
thank you in advance
hans_v
All-Star
35986 Points
6550 Posts
Re: problems datasourceAccess & detailsview
May 01, 2012 09:31 AM|LINK
Are you sure, because the error (translated in English : no value given for one or more required parameters) is telling that you didn't specify any parameters in the Insert- and Update-Parameter collections. Alss, in your update statement, you don't need to update the Key field (Id_compte). Assuming this field is a Autonumber Field, you don't need to include this field in the insertcommand.
<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="~/App_Data/baseCompte.accdb"
SelectCommand="SELECT [id_compte], [titulaire], [solde] FROM [Compte] ORDER BY [id_compte]"
InsertCommand="INSERT INTO [Compte]([titulaire], [solde]) VALUES (@titulaire, @solde)"
DeleteCommand="DELETE FROM [Compte] WHERE [id_compte] = @id_compte"
UpdateCommand="UPDATE [Compte] SET [titulaire] = @titulaire, [solde] = @solde WHERE [id_compte] = @id_compte">
<InsertParameters>
<asp:Parameter Name="titulaire" />
<asp:Parameter Name="solde" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="titulaire" />
<asp:Parameter Name="solde" />
<asp:Parameter Name="id_compte" />
</UpdateParameters>
<DeleteParameters>
<asp:Parameter Name="id_compte" />
</DeleteParameters>
</asp:AccessDataSource>
Note that the order of the parameters in the collection should match the order the parameters (first) appear in the command.
Finally, in order to make the UPDATE and DELETE work, you need to specify the DataKeyNames Property of the DetailsView
<asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True"
AutoGenerateRows="False" DataSourceID="AccessDataSource1" Height="50px"
Width="298px" onpageindexchanging="DetailsView1_PageIndexChanging"
EnablePagingCallbacks="True" DataKeyNames="id_compte">
karim88
0 Points
6 Posts
Re: problems datasourceAccess & detailsview
May 01, 2012 01:22 PM|LINK
thank you very much hans_v
I just add DataKeyNames="id_compte"
it works