Wrox Programmer Forums
|
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 12th, 2013, 03:39 PM
Registered User
 
Join Date: Oct 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default error while hitting submit button

Greets all,
i have a gridview, image link below

CLICK TO VIEW MY GRIDVIEW

source code
Code:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
            DataSourceID="AccessDataSource1" OnRowDataBound="GridView1_RowDataBound"
              ShowFooter="True" CellPadding="4" ForeColor="#333333" GridLines="None"
            onselectedindexchanged="GridView1_SelectedIndexChanged" >
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
            <Columns>
                <asp:BoundField DataField="name" HeaderText="name" SortExpression="name" FooterText="total" />
                
                <asp:TemplateField HeaderText="maths" >
                <ItemTemplate>
                    <asp:TextBox ID="mat" runat="server" Text='<%# Eval("maths").ToString() %>'></asp:TextBox>
                    
                </ItemTemplate>
                <FooterTemplate>
                    <asp:Label ID="mathstotal" runat="server" ></asp:Label>
                </FooterTemplate>
                </asp:TemplateField>

                <asp:TemplateField HeaderText="science">
                <ItemTemplate>
                    <asp:TextBox ID="sci" runat="server" Text='<%# Eval("science").ToString() %>'></asp:TextBox>
                    
                </ItemTemplate>
                <FooterTemplate>
                    <asp:Label ID="scitotal" runat="server" ></asp:Label>
                </FooterTemplate>
                </asp:TemplateField>

                <asp:TemplateField HeaderText="computer">
                <ItemTemplate>
                    <asp:TextBox ID="com" runat="server" Text='<%# Eval("computer").ToString() %>'></asp:TextBox>
                </ItemTemplate>
                <FooterTemplate>
                    <asp:Label ID="comtotal" runat="server" ></asp:Label>
                </FooterTemplate>
                </asp:TemplateField>

                <asp:TemplateField HeaderText="total marks">
                <ItemTemplate>
                  <asp:Label ID="tot" runat="server" Text='<%# Convert.ToInt32(Eval("maths"))+Convert.ToInt32(Eval("science"))+Convert.ToInt32(Eval("computer")) %>'></asp:Label>
                </ItemTemplate>
                <FooterTemplate>
                    <asp:Label ID="total" runat="server" ></asp:Label>
                </FooterTemplate>
                </asp:TemplateField>
            </Columns>
            <EditRowStyle BackColor="#999999" />
            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
            <SortedAscendingCellStyle BackColor="#E9E7E2" />
            <SortedAscendingHeaderStyle BackColor="#506C8C" />
            <SortedDescendingCellStyle BackColor="#FFFDF8" />
            <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
        </asp:GridView>
        <asp:AccessDataSource ID="AccessDataSource1" runat="server"
            DataFile="~/App_Data/Test.accdb"
            SelectCommand="SELECT [name], [maths], [science], [computer] FROM [Table1]">
        </asp:AccessDataSource>
souce of submit button

Quote:
protected void Button1_Click(object sender, EventArgs e)
{

string connstr = "provider=microsoft.ace.oledb.12.0;data source=c:\\users\\jammy\\documents\\visual studio 2010\\websites\\testing\\app_data\\test.accdb;pers ist security info=true";
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = connstr;

OleDbDataAdapter adapter = new OleDbDataAdapter();
adapter.InsertCommand = new OleDbCommand();
adapter.InsertCommand.CommandText = "insert into table1(name, maths, science, computer)" + " values( name, maths, science, computer);";
conn.Open();
adapter.InsertCommand.Connection = conn;
adapter.InsertCommand.ExecuteNonQuery();

}
the problem is when i am hitting SUBMIT button, i got this error

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
use an anchor to submit, or set image for submit button mikezx10 Classic ASP Basics 1 March 22nd, 2010 09:40 AM
Hitting the close button of form causes message to appear Dernty BOOK: Professional Outlook 2007 Programming ISBN: 978-0-470-04994-5 0 June 10th, 2009 03:28 PM
Preventing Data Loss when hitting back button IronStar Javascript How-To 8 July 23rd, 2005 07:00 PM
submit the form by hitting the enter key rajiv_software Classic ASP Basics 1 April 26th, 2005 07:19 AM
How do I flag an error message on a Submit button? Lucy Javascript How-To 1 January 21st, 2005 06:24 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.