title: How can I Insert data into SQL Server using VBNet
body: <p>I am new to <code>vb.net</code> I need to insert  data in table by using vb.net please can any one help</p>
  
  <p>I have tried this </p>
  
  <p>Here I tried Sample Code </p>
  
  <p>I got this exception <code>Column name or number of supplied values does not match table definition.</code>
  thanks advance</p>
  
  <pre class="lang-vb prettyprint-override"><code>Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As  System.EventArgs)  Handles btnSave.Click
  
      Dim strName As String = txtName.Text
      Dim strId As String = txtID.Text
      Dim strPhone As String = txtPhone.Text
      Dim strBranch As String = cmboxBranch.SelectedItem.ToString()
      Dim  strCourse As String = cmbboxCourse.SelectedItem.ToString()
      Dim dblFee As Double = Double.Parse(txtFee.Text) 
  
      Dim strCommand As String = "insert into student values('" &amp; strName &amp; "','" &amp; strId &amp;    "','" &amp; strPhone &amp; "','" &amp; strBranch &amp; "','" &amp; strCourse &amp; "'," &amp; dblFee &amp; ")"
  
      Dim command As SqlCommand = New SqlCommand(strCommand, connection)
      command.CommandType = CommandType.Text
  
      '' MsgBox(strCommand) 
  
      connection.Open()
      If (command.ExecuteNonQuery().Equals(1)) Then
          MsgBox("Information stored in database")
      Else
          MsgBox("Not stored in database")
      End If
  
  End Sub
  </code></pre>