Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6901899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:43:52+00:00 2026-05-27T07:43:52+00:00

I am trying to insert a new product into my database, although I am

  • 0

I am trying to insert a new product into my database, although I am unsure how to make my Add Product button work properly. The gridview helped me in setting up the edit/update/delete and works perfectly. But I am not sure how to make my button communicate and add from my 4 textboxes to my database database. I am not sure if the code below will be helpful.

To explain though the bottom table contains the text boxes I am trying to take values from to insert into my database. Maybe there is a property I am missing?

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
    DataKeyNames="ProductCode" DataSourceID="AccessDataSource1">
    <Columns>
        <asp:BoundField DataField="ProductCode" HeaderText="ProductCode" 
            ReadOnly="True" SortExpression="ProductCode" />
        <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
        <asp:BoundField DataField="Version" HeaderText="Version" 
            SortExpression="Version" />
        <asp:BoundField DataField="ReleaseDate" HeaderText="ReleaseDate" 
            SortExpression="ReleaseDate" />
        <asp:CommandField ButtonType="Button" ShowEditButton="True" />
        <asp:CommandField ButtonType="Button" ShowDeleteButton="True" />
    </Columns>
</asp:GridView>
<asp:AccessDataSource ID="AccessDataSource1" runat="server" 
    DataFile="~/App_Data/TechSupport.mdb" 
    DeleteCommand="DELETE FROM [Products] WHERE [ProductCode] = ?" 
    InsertCommand="INSERT INTO [Products] ([ProductCode], [Name], [Version], [ReleaseDate]) VALUES (?, ?, ?, ?)" 
    SelectCommand="SELECT * FROM [Products] ORDER BY [ProductCode]" 
    UpdateCommand="UPDATE [Products] SET [Name] = ?, [Version] = ?, [ReleaseDate] = ? WHERE [ProductCode] = ?">
    <DeleteParameters>
        <asp:Parameter Name="ProductCode" Type="String" />
    </DeleteParameters>
    <UpdateParameters>
        <asp:Parameter Name="Name" Type="String" />
        <asp:Parameter Name="Version" Type="Decimal" />
        <asp:Parameter Name="ReleaseDate" Type="DateTime" />
        <asp:Parameter Name="ProductCode" Type="String" />
    </UpdateParameters>
    <InsertParameters>
        <asp:Parameter Name="ProductCode" Type="String" />
        <asp:Parameter Name="Name" Type="String" />
        <asp:Parameter Name="Version" Type="Decimal" />
        <asp:Parameter Name="ReleaseDate" Type="DateTime" />
    </InsertParameters>
</asp:AccessDataSource>
<br />
<br />
To add a new Product, enter the product information below and Click Add Product!<br />
<br />
<table border="0" cellpadding="0" cellspacing="6"><tr><td>Product Code:</td><td><asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></td><td>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
        ErrorMessage="RequiredFieldValidator" ControlToValidate="TextBox1"></asp:RequiredFieldValidator></td></tr>
    <tr><td>Name:</td><td> <asp:TextBox ID="TextBox2" runat="server" Width="349px"></asp:TextBox></td><td>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
            ErrorMessage="RequiredFieldValidator" ControlToValidate="TextBox2"></asp:RequiredFieldValidator></td></tr>
    <tr><td>Version:</td><td><asp:TextBox ID="TextBox3" runat="server"></asp:TextBox></td><td>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
            ErrorMessage="RequiredFieldValidator" ControlToValidate="TextBox3"></asp:RequiredFieldValidator>
        </td></tr>
    <tr><td>Release Date:</td><td><asp:TextBox ID="TextBox4" runat="server">mm/dd/yy</asp:TextBox></td><td>
        &nbsp;</td></tr>
    </table>
    <br />
    <br />
<asp:Button ID="Button1" runat="server" Text="Add Product" />
</asp:Content>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:43:53+00:00Added an answer on May 27, 2026 at 7:43 am

    Convert insert parameters from Parameter to ControlParameter, use appropriate textbox ID for ControlID property value for each parameter and Text for PropertyName property value (i.e. change InserParameters section as below). After that, place following code in Button1 Click event handler: AccessDataSource1.Insert().

    <InsertParameters>
        <asp:ControlParameter Name="ProductCode" Type="String" ControlID="TextBox1" PropertyName="Text" />
        <asp:ControlParameter Name="Name" Type="String" ControlID="TextBox2" PropertyName="Text"/>
        <asp:ControlParameter Name="Version" Type="Decimal" ControlID="TextBox3" PropertyName="Text"/>
        <asp:ControlParameter Name="ReleaseDate" Type="DateTime" ControlID="TextBox4" PropertyName="Text" ConvertEmptyStringToNull="true"/>
    </InsertParameters>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to insert some new objects into a firebird database using NHibernate. I
I'm trying to insert new records into SQLite database from Python code. con =
I'm trying to insert new records into a SQL CE 4 database with LINQPad
I'm trying to insert something into a local database, but it doesn't work.. ModelContainer
I was trying to insert new data into an existing XML file, but it's
Trying to do an insert, I have: jdbcTemplate.update(insert into...., new Object[]{foo.getId(), foo.getName()}) foo.getId() returns
Trying to insert 315K Gif files into an Oracle 10g database. Everytime I get
I'm trying to get a basic DataGridView to insert new rows into a table.
I'm trying to insert the data into my database which has 2 tables Products
I am trying to insert new lines into an Excel XML document. The entity

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.