title: unable to save data in database in vb.net
body: <p>I need a simple program which add,edit,save,delete data from database in vb.net. I have tried dataset or  sqlcommandbuilder but both are not working.
  please look at my code I have used with sqlcommandbuilder, it is not saving anything in database.
  Please provide simplest method to save data in database from dataset or direct from textbox.
  In this vb.net is not showing any error but not saving </p>
  
  <pre><code>'set up a connection string'
  Dim connectionstring As String
  
  connectionstring = "Data Source=|DataDirectory|\inventorymanage.sdf;Password='XXX'"
  
  Dim sqlquery As String = "SELECT * FROM ledger"
  
  'create connection'
  Dim connaction As SqlCeConnection = New SqlCeConnection(connectionstring)
  
  Try
      'open connection'
      connaction.Open()
  
  
  
      'create data adapter'
      Dim da As SqlCeDataAdapter = New SqlCeDataAdapter(sqlquery, connaction)
  
      'create command builder'
      Dim commandbuilder As SqlCeCommandBuilder = New SqlCeCommandBuilder(da)
  
  
      'create dataset'
      Dim ds As New DataSet
  
      'fill dataset'
      da.Fill(ds, "ledger")
  
      'get datatable'
      Dim dt As DataTable = ds.Tables("ledger")
  
      Dim dsnewrow As DataRow
  
      dsnewrow = ds.Tables("ledger").NewRow()
  
  
  
      ds.Tables("ledger").Rows.Add(dsnewrow)
      With dt
          ' modify data rows in ledger
          .Rows(0).Item(1) = Textbox4.Text
          .Rows(0).Item(2) = TextBox5.Text
      End With
  
  
  
      da.Update(ds, "ledger")
  
  
      MsgBox("record added")
  Catch ex As SqlCeException
      MsgBox("you got error" &amp; ex.ToString &amp; vbCrLf)
  
  Finally
      'close connection'
      connaction.Close()
  End Try
  </code></pre>