title: MSSQL Query Error: "Cannot insert the value NULL into column <X>."
body: <p><img src="https://i.stack.imgur.com/pyYWM.png" alt="alt text"></p>
  
  <p>Following error occurs in /// this coding "</p>
  
  <p><strong><em>Cannot insert the value NULL into column 'boarding', table 'C:\USERS\VBI SERVER\DOCUMENTS\VISUAL STUDIO 2008\WEBSITES\VOLVO\APP_DATA\ASPNETDB.MDF.dbo.boardingpt'; column does not allow nulls. INSERT fails. The statement has been terminated.</em></strong></p>
  
  <pre><code>Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
          Dim con As New SqlConnection
          Dim cmd As New SqlCommand
          con.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True"
          con.Open()
          cmd.Connection = con
          cmd.CommandText = "INSERT INTO boardingpt (service, travelid, bdpt_name, time) VALUES('" &amp; Trim(TextBox3.Text.ToString) &amp; "', '" &amp; Trim(TextBox4.Text.ToString) &amp; "', '" &amp; Trim(TextBox1.Text.ToString) &amp; "','" &amp; Trim(TextBox2.Text.ToString) &amp; "')"
          cmd.ExecuteNonQuery()
          con.Close()
  
      End Sub
  </code></pre>