title: asp.net c# data to a database
body: <p>I have been at this for two days now with no luck. 
  The problem is I am trying to input data into my sql server database via a web form. every time I try to run I am getting errors .</p>
  
  <p><strong>Bellow is the Error I am Getting when I run the code</strong>
  <img src="https://i.stack.imgur.com/EBTBP.png" alt="Error Image"></p>
  
  <p><strong>this is the code for the web form</strong></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.SqlClient;
  using System.Data;
  
  namespace WebApplication1
  {
      public partial class _Default : Page
      {
          protected void Page_Load(object sender, EventArgs e)
          {
  
          }
  
          protected void Button1_Click(object sender, EventArgs e)
          {
              SqlConnection cs = new SqlConnection ("Data Source = SQLEXSPRESS; Initial Catalog = OMS; Integrated Security = true");
              SqlDataAdapter da = new SqlDataAdapter ();
              da.InsertCommand = new SqlCommand("INSERT INTO Customer tbl (FirstName,LastName) Customer VALUES (@FirstName,@LastName)", cs);
              da.InsertCommand.Parameters.Add("@FirstName", SqlDbType.VarChar).Value = firstname.Text;
              da.InsertCommand.Parameters.Add("@LastName", SqlDbType.VarChar).Value = lastname.Text;
  
              cs.Open();
              da.InsertCommand.ExecuteNonQuery(); // Error occurs here
              cs.Close();
          }
  
          protected void firstname_TextChanged(object sender, EventArgs e)
          {
  
          }
  
          protected void lastname_TextChanged(object sender, EventArgs e)
          {
  
          }
      }
  }
  </code></pre>
  
  <p><strong>This is my database Table code</strong></p>
  
  <pre><code>CREATE TABLE [dbo].[Customer] (
  [CustomerID] INT          IDENTITY (1, 1) NOT NULL,
  [FirstName]  VARCHAR (50) NULL,
  [LastName]   VARCHAR (50) NULL,
  [Address]    VARCHAR (50) NOT NULL,
  [City]       VARCHAR (25) NOT NULL,
  [Postcode]   VARCHAR (10) NOT NULL,
  [Country]    VARCHAR (50) NOT NULL,
  [Modified]   ROWVERSION   NOT NULL,
  PRIMARY KEY CLUSTERED ([CustomerID] ASC)
  </code></pre>
  
  <p>);</p>
  
  <p>Any help will be greatly appreciated. </p>