title: Why do I get System.Data.SqlClient.SqlInternalConnection.OnError... in ASP.NET?
body: <p>I am fairly new to ASP.NET and I am trying to save the data of my web form into the database. I have tested the database table connection with the Aspx file and it loads the data of the table(manually entered data) into the table correctly in the browser. </p>
  
  <p>However, when I fill up the form and press Save, I get this error:<a href="http://i.stack.imgur.com/QRAxr.png" rel="nofollow">Screenshot of error message</a></p>
  
  <p>This is my code of 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.SqlClient;
  using System.Configuration;
  
  public partial class _Default : Page
  {
      protected void Page_Load(object sender, EventArgs e)
   {
      if(IsPostBack)
          {
  
          SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["RegistrationConnectionString"].ConnectionString);
          conn.Open();
  
  
          Response.Write("Database connection successful");
  
  
          conn.Close();
      }
  
  }
  
  
  
  protected void Button2_Click(object sender, EventArgs e)
  {
      Response.Write("Database connection successful");
  
  }
  
  protected void Button1_Click(object sender, EventArgs e)
  {
      try
      {
          SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["RegistrationConnectionString"].ConnectionString);
          conn.Open();
  
          string insertQuery = "insert into Table (Name, Address, Phone, Email, Source, Message) values (@name, @address, @phone, @email, @source, @message");
          SqlCommand com = new SqlCommand(insertQuery, conn);
          com.Parameters.AddWithValue("@name", Name.Text);
          com.Parameters.AddWithValue("@address", Address.Text);
          com.Parameters.AddWithValue("@phone", Phone.Text);
          com.Parameters.AddWithValue("@email", Email.Text);
          com.Parameters.AddWithValue("@source", Source.SelectedItem.ToString());
          com.Parameters.AddWithValue("@message", "text");
  
          com.ExecuteNonQuery();
  
          Response.Write("Data is saved");
  
          conn.Close();
  
  
      }
  
      catch (Exception ex)
      {
  
          Response.Write("Error:" + ex.ToString());
  
      }
  
  
  }
  }
  </code></pre>
  
  <p>My error says this:</p>
  
  <p>System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action<code>1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean&amp; dataReady) at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task&amp; task, Boolean asyncWrite, SqlDataReader ds, Boolean describeParameterEncryptionRequest) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource</code>1 completion, Int32 timeout, Task&amp; task, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at _Default.Button1_Click(Object sender, EventArgs e) in D:\documents\visual studio 2015\WebSites\Enquiry Tracking Sys\Default.aspx.cs:line 45 ClientConnectionId:6c142f6c-40d7-4977-b75d-8fb0d774b0c6 Error Number:156,State:1,Class:15 </p>