title: When click on button the data is'nt saving in the database? ASP.NET
body: <p>I'm trying to save some information from a page into the database, I think that my used code is true, but I don't know why it not saved to access database?</p>
  
  <p>Database name--> <code>Database1</code></p>
  
  <p>Table Name --> <code>Table1</code></p>
  
  <p>Fields Name --> <code>Name,Email,Mobile,Laptop,WhatYouNeedFromUs,WhereAreYouFrom</code></p>
  
  <p>Type--><code>Text</code></p>
  
  <p>The connection is fine just the data not inserted and saved into database I don't know why!!</p>
  
  <p>ContactUs.aspx</p>
  
  <pre><code>&lt;%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="ContactUs.aspx.cs" Inherits="ContactUs" %&gt;
  
  
  &lt;asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"&gt;
  &lt;/asp:Content&gt;
  &lt;asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"&gt;
  
      &lt;asp:Table ID="Table1" runat="server" style="width:80%; margin-left:auto; margin-right:auto; margin-top:50px; background-color:#fff" &gt;
          &lt;asp:TableRow ID="TableRow1" runat="server"&gt;
              &lt;asp:TableCell ID="TableCell1" runat="server" Width="50%" Text="Name " HorizontalAlign="Center" BorderColor="black" VerticalAlign="Middle" Font-Bold="True" BorderWidth="1px"&gt;&lt;/asp:TableCell&gt;
              &lt;asp:TableCell ID="TableCell2" runat="server" BorderColor="black" BorderWidth="1px"&gt;&lt;asp:TextBox ID="TextBox1" runat="server" Height="50px" 
          Width="99%" MaxLength="20" Font-Size="Large"&gt;&lt;/asp:TextBox&gt;
  &lt;/asp:TableCell&gt;
          &lt;/asp:TableRow&gt;
  
          &lt;asp:TableRow ID="TableRow2" runat="server"&gt;
              &lt;asp:TableCell ID="TableCell3" runat="server" Width="50%" Text="Email " HorizontalAlign="Center" BorderColor="black" VerticalAlign="Middle" Font-Bold="True" BorderWidth="1px"&gt;&lt;/asp:TableCell&gt;
              &lt;asp:TableCell ID="TableCell4" runat="server" BorderColor="black" BorderWidth="1px"&gt;&lt;asp:TextBox ID="TextBox2" runat="server" Height="50px" 
          Width="99%" MaxLength="20" Font-Size="Large"&gt;&lt;/asp:TextBox&gt;
  &lt;/asp:TableCell&gt;
          &lt;/asp:TableRow&gt;
  
          &lt;asp:TableRow ID="TableRow3" runat="server"&gt;
              &lt;asp:TableCell ID="TableCell5" runat="server" Width="50%" Text="Mobile Phone " HorizontalAlign="Center" BorderColor="black" VerticalAlign="Middle" Font-Bold="True" BorderWidth="1px"&gt;&lt;/asp:TableCell&gt;
              &lt;asp:TableCell ID="TableCell6" runat="server" BorderColor="black" BorderWidth="1px"&gt;&lt;asp:TextBox ID="TextBox3" runat="server" Height="50px" 
          Width="99%" MaxLength="20" Font-Size="Large"&gt;&lt;/asp:TextBox&gt;
  &lt;/asp:TableCell&gt;
          &lt;/asp:TableRow&gt;
  
          &lt;asp:TableRow ID="TableRow4" runat="server"&gt;
              &lt;asp:TableCell ID="TableCell7" runat="server"  CellPadding="5" CellSpacing="5" VerticalAlign="Top" Font-Bold="True" Font-Size="Large" HorizontalAlign="Right"&gt;Which Laptop You Want?&lt;/asp:TableCell&gt;
              &lt;asp:TableCell ID="TableCell8" runat="server"  CellPadding="5" CellSpacing="5" ColumnSpan="2"&gt;&lt;asp:RadioButtonList ID="RadioButtonList1" runat="server" Font-Bold="True" Font-Size="Large"&gt;
          &lt;asp:ListItem&gt;Hp&lt;/asp:ListItem&gt;
  
  
  &lt;asp:ListItem&gt;Samsung&lt;/asp:ListItem&gt;
  
  
  &lt;asp:ListItem&gt;Sony&lt;/asp:ListItem&gt;
  
  
  &lt;asp:ListItem&gt;Lenovo&lt;/asp:ListItem&gt;
  
  
  &lt;/asp:RadioButtonList&gt;
  &lt;/asp:TableCell&gt;
          &lt;/asp:TableRow&gt;
  
          &lt;asp:TableRow ID="TableRow5" runat="server"&gt;
              &lt;asp:TableCell ID="TableCell9" runat="server" Width="50%" Text="What you need from us?" HorizontalAlign="Center" BorderColor="black" VerticalAlign="Middle" Font-Bold="True" BorderWidth="1px"&gt;&lt;/asp:TableCell&gt;
              &lt;asp:TableCell ID="TableCell10" runat="server" BorderColor="black" BorderWidth="1px"&gt;&lt;asp:TextBox ID="TextBox4" placeholder="Enter what you want" runat="server" Height="50px" 
          Width="99%" MaxLength="200" Font-Size="Large"&gt;&lt;/asp:TextBox&gt;
  &lt;/asp:TableCell&gt;
          &lt;/asp:TableRow&gt;
  
          &lt;asp:TableRow ID="TableRow6" runat="server"&gt;
              &lt;asp:TableCell ID="TableCell11" runat="server" Width="50%" Text="Where Are You From? " HorizontalAlign="Center" BorderColor="black" VerticalAlign="Middle" Font-Bold="True" BorderWidth="1px"&gt;&lt;/asp:TableCell&gt;
              &lt;asp:TableCell ID="TableCell12" runat="server" BorderColor="black" BorderWidth="1px"&gt;&lt;asp:ListBox ID="ListBox1" runat="server" Rows="1" Width="99%"&gt;
          &lt;asp:ListItem&gt;Kurdistan&lt;/asp:ListItem&gt;
  
  &lt;asp:ListItem&gt;Iraq&lt;/asp:ListItem&gt;
  
  &lt;asp:ListItem&gt;Italy&lt;/asp:ListItem&gt;
  
  &lt;asp:ListItem&gt;Netherlands&lt;/asp:ListItem&gt;
  
  &lt;/asp:ListBox&gt;
  
  &lt;/asp:TableCell&gt;
          &lt;/asp:TableRow&gt;
  
  
          &lt;asp:TableRow ID="TableRow7" runat="server" &gt;
              &lt;asp:TableCell ID="TableCell13" runat="server" ColumnSpan="2" VerticalAlign="Middle" HorizontalAlign="Center" Font-Size="Larger"&gt;&lt;asp:Button ID="Button1"  style="margin-top:20px;" runat="server" BackColor="Black" Font-Bold="True" 
          Font-Size="Larger" ForeColor="Red" Text="Submit" /&gt;&lt;/asp:TableCell&gt;
          &lt;/asp:TableRow&gt;
  
  
      &lt;/asp:Table&gt;
  
      &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
      &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
  &lt;/asp:Content&gt;
  </code></pre>
  
  <p>C# code:
  ContaceUs.aspx.cs</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  using System.Data.OleDb;
  
  public partial class ContactUs : System.Web.UI.Page
  {
      protected void Page_Load(object sender, EventArgs e)
      {
  
      }
  
      protected void Button1_Click(object sender, EventArgs e)
      {
          OleDbConnection connection = new OleDbConnection();
          connection.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Sevar\Documents\Database1.mdb;
  Persist Security Info=False;";
          connection.Open();
  
          OleDbCommand command = new OleDbCommand();
          command.Connection = connection;
  
          command.CommandText = "Insert into Table1 (Name,Email,Mobile,Laptop,WhatYouNeedFromUs,WhereAreYouFrom) Values('" + TextBox1 + "','" + TextBox2 + "','" + TextBox3 + "','" + RadioButtonList1 + "','" + TextBox4 + "','" + ListBox1 + "')";
          command.ExecuteNonQuery();
          connection.Close();
      }
  }
  </code></pre>