title: Insert data into SQL Server using VB .NET
body: <p>i'm trying to insert some sample data into a sql server.</p>
  
  <p>I'm using Visual Basic 2010 Express.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>Public Sub insert()
  
      Dim myconnect As New SqlClient.SqlConnection
      myconnect.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\DATABASE_NUOVO.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
  
  
      Dim mycommand As SqlClient.SqlCommand = New SqlClient.SqlCommand()
      mycommand.Connection = myconnect
      mycommand.CommandText = "INSERT INTO utenti (nome) VALUES ('mario')"
      myconnect.Open()
  
      Try
          mycommand.ExecuteNonQuery()
      Catch ex As System.Data.SqlClient.SqlException
          MsgBox(ex.Message)
      End Try
      myconnect.Close()
      MsgBox("Success")
  
  End Sub
  </code></pre>
  
  <p>The code seems to run correctly, but when i look into the database after running the debug i don't see the sample data.</p>
  
  <p>Where is the problem?</p>
  
  <p>Thanks</p>