title: How to 'insert' data into database via VB
body: <p>Stuggling a bit here. Trying to develop the code to link user input into my database, in the form of a book record. for example the user would be asked to enter their name address etc. But the code I have used does not seem to execute because I continually get the same error.</p>
  
  <pre><code>Line 12:         Dim con As New SqlConnection
  Line 13:         Dim inscmd As New SqlCommand
  Line 14:         con.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("Database.My.MySettings.Database1ConnectionString1").ConnectionString
  Line 15:         con.Open()
  Line 16:         inscmd.CommandText = ("insert into booking values('" + txtfirstname.Text + "', " + txtSurname.Text + "', " + txtAddressline1.Text + "', " + txtAddressline2.Text + "', " + txtPostcode.Text + "', " + txtTime.Text + "', " + txtPeople.Text + "', " + txtDropoff1.Text + "', " + txtDropoff2.Text + "', " + txtDropoffpost.Text + "")
  </code></pre>
  
  <p>It is line 14 that contains the error but I dont know why. This is my code;</p>
  
  <pre><code>Protected Sub btnsubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles  btnsubmit.Click
      Dim con As New SqlConnection
      Dim inscmd As New SqlCommand
      con.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("Database.My.MySettings.Database1ConnectionString1").ConnectionString
      con.Open()
      inscmd.CommandText = ("insert into booking values('" + txtfirstname.Text + "', " + txtSurname.Text + "', " + txtAddressline1.Text + "', " + txtAddressline2.Text + "', " + txtPostcode.Text + "', " + txtTime.Text + "', " + txtPeople.Text + "', " + txtDropoff1.Text + "', " + txtDropoff2.Text + "', " + txtDropoffpost.Text + "")
      Print(inscmd.CommandText)
      inscmd.Connection = con
      inscmd.ExecuteNonQuery()
      con.Close()
      inscmd.Parameters.Clear()
  
      MsgBox("Your booking has been successfully")
      con.Close()
  
  End Sub
  </code></pre>