Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi, posting because when i click on update button on the gridview, gives me this error. My teacher already tried and nothing, but if i use another Database he can do it well.

I will be copy the code backdown.


XML
<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
    </style>
</head>
<body background="Fundos/padrao1.png">
    <form id="form1" runat="server">
    <div style="text-align: center">

        <asp:ImageButton ID="ImageButton1" runat="server"
            ImageUrl="~/Fundos/Logotipo2.png" PostBackUrl="~/PagAdmin.aspx" Width="944px" />

    </div>
    <p style="text-align: center">
        <asp:Label ID="Label1" runat="server" BorderColor="Red" BorderStyle="Solid"
            Font-Size="X-Large" ForeColor="White" Height="26px" Text="Editar/Eliminar"
            Width="418px"></asp:Label>
    </p>
    <table align="center" class="style1" style="text-align: center">
        <tr>
            <td>
                &nbsp;</td>
            <td>
                <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
                    BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px"
                    CellPadding="3" CellSpacing="2" DataKeyNames="Id_Artigo"
                    DataSourceID="AccessDataSource1">
                    <Columns>
                        <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                        <asp:BoundField DataField="Id_Artigo" HeaderText="Id_Artigo" ReadOnly="True"
                            SortExpression="Id_Artigo" />
                        <asp:BoundField DataField="Marca" HeaderText="Marca" SortExpression="Marca" />
                        <asp:BoundField DataField="Modelo" HeaderText="Modelo"
                            SortExpression="Modelo" />
                        <asp:BoundField DataField="Preço" DataFormatString="{0:c}" HeaderText="Preço"
                            SortExpression="Preço" />
                        <asp:BoundField DataField="Tipo" HeaderText="Tipo" SortExpression="Tipo" />
                        <asp:BoundField DataField="Stock" HeaderText="Stock" SortExpression="Stock" />
                        <asp:BoundField DataField="Imagem" HeaderText="Imagem" SortExpression="Imagem"
                            Visible="False" />
                        <asp:ImageField DataImageUrlField="Imagem" HeaderText="Imagem">
                            <ControlStyle Height="200px" Width="200px" />
                            <ItemStyle Height="30px" Width="60px" />
                        </asp:ImageField>
                    </Columns>
                    <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
                    <HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
                    <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
                    <RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
                    <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
                    <SortedAscendingCellStyle BackColor="#FFF1D4" />
                    <SortedAscendingHeaderStyle BackColor="#B95C30" />
                    <SortedDescendingCellStyle BackColor="#F1E5CE" />
                    <SortedDescendingHeaderStyle BackColor="#93451F" />
                </asp:GridView>
                <asp:AccessDataSource ID="AccessDataSource1" runat="server"
                    DataFile="~/SI.accdb"
                    DeleteCommand="DELETE FROM [Artigos] WHERE (([Id_Artigo] = ?) OR ([Id_Artigo] IS NULL AND ? IS NULL))"
                    InsertCommand="INSERT INTO [Artigos] ([Id_Artigo], [Marca], [Modelo], [Preço], [Tipo], [Imagem], [Stock]) VALUES (?, ?, ?, ?, ?, ?, ?)"
                    SelectCommand="SELECT * FROM [Artigos]"
                    UpdateCommand="UPDATE [Artigos] SET [Marca] = ?, [Modelo] = ?, [Preço] = ?, [Tipo] = ?, [Imagem] = ?, [Stock] = ? WHERE (([Id_Artigo] = ?) OR ([Id_Artigo] IS NULL AND ? IS NULL))">
                    <DeleteParameters>
                        <asp:Parameter Name="Id_Artigo" Type="Int32" />
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:Parameter Name="Id_Artigo" Type="Int32" />
                        <asp:Parameter Name="Marca" Type="String" />
                        <asp:Parameter Name="Modelo" Type="String" />
                        <asp:Parameter Name="Preço" Type="Decimal" />
                        <asp:Parameter Name="Tipo" Type="Int32" />
                        <asp:Parameter Name="Imagem" Type="String" />
                        <asp:Parameter Name="Stock" Type="String" />
                    </InsertParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="Marca" Type="String" />
                        <asp:Parameter Name="Modelo" Type="String" />
                        <asp:Parameter Name="Preço" Type="Decimal" />
                        <asp:Parameter Name="Tipo" Type="Int32" />
                        <asp:Parameter Name="Imagem" Type="String" />
                        <asp:Parameter Name="Stock" Type="String" />
                        <asp:Parameter Name="Id_Artigo" Type="Int32" />
                    </UpdateParameters>
                </asp:AccessDataSource>



            </td>
            <td>
                &nbsp;</td>
        </tr>
    </table>
    </form>
</body>
</html>
Posted
Comments
DipsMak 28-Feb-14 7:22am    
what error message you are getting
JoCodes 28-Feb-14 7:34am    
Post the error and which line it throws?
Sd10813 28-Feb-14 8:31am    
Erro de servidor na aplicação '/Módulo 8-ProjetoBrunoCosta'.

Não foi fornecido nenhum valor para um ou mais parâmetros necessários.

Descrição: Exceção não processada ao executar o pedido Web atual. Consulte o rastreio da pilha para obter mais informações sobre o erro e o respetivo ponto de origem no código.

Detalhes da Exceção: System.Data.OleDb.OleDbException: Não foi fornecido nenhum valor para um ou mais parâmetros necessários.

Erro de origem:

Foi gerada uma Exceção não processada durante a execução do pedido Web atual. As informações relativas à origem e localização da Exceção poderão ser identificadas através da utilização do rastreio da pilha de exceções abaixo.

Rastreio da pilha:


[OleDbException (0x80040e10): Não foi fornecido nenhum valor para um ou mais parâmetros necessários.]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr) +1165704
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +247
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +189
System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +58
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +162
System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +107
System.Web.UI.WebControls.SqlDataSourceView.ExecuteDbCommand(DbCommand command, DataSourceOperation operation) +378
System.Web.UI.WebControls.SqlDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) +670
System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) +87
System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32 rowIndex, Boolean causesValidation) +1210
System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +738
System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs e) +89
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) +88
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +121
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +156
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) +9703558
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724

Informações da versão: Versão do Microsoft .NET Framework:4.0.30319; Versão do ASP.NET:4.0.30319.34009

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