title: How to save to SQL Server Express database in visual studio 2005
body: <p>I am a beginner in vb.net and would like to know how to connect a window form to a SQL Server Express database in Visual Studio 2005 so that we can later on perform add, search, update and delete on a record.</p>
  
  <p>here is my code:</p>
  
  <pre><code>Dim mycommand As SqlCommand
  Dim dr As SqlDataReader
  Dim dr1 As SqlDataReader
  Dim ra As Integer
  
  Private Sub cmdsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)       Handles cmdsave.Click
  
      Using myconnection As SqlConnection = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\database\app.mdf;Integrated Security=True;User Instance=True")
          myconnection.Open()
          mycommand = New SqlCommand("insert into staff([FirstName],[LastName],[Address],[DOB], " &amp; _
                                     "[TelephoneNum], [DateJoinIn], [HighestQualifi], [AppointedAs], [Salary]) " &amp; _
                                     "VALUES (@first, @last, @address, @dob, @tel, @dateJ, @highQ, @appointed, @sal)", myconnection)
  
          mycommand.Parameters.AddWithValue("@first", txtfname.Text)
          mycommand.Parameters.AddWithValue("@last", txtlname.Text)
          mycommand.Parameters.AddWithValue("@address", txtaddress.Text)
          mycommand.Parameters.AddWithValue("@dob", txtdob.Text)
          mycommand.Parameters.AddWithValue("@tel", txttelephone.Text)
          mycommand.Parameters.AddWithValue("@dateJ", txtdjoinin.Text)
          mycommand.Parameters.AddWithValue("@highQ", txthqualifi.Text)
          mycommand.Parameters.AddWithValue("@appointed", txtappoint.text)
          mycommand.Parameters.AddWithValue("@sal", txtsalary.Text)
          mycommand.ExecuteNonQuery()
  
          myconnection.Close()
      End Using
  
  End Sub
  </code></pre>
  
  <p>The problem is that it is not saving in my database????? pls help out</p>