title: Using an update statement for Access database (VB 2008)
body: <p>I'm trying to create an update statement for my program that will update a database using SQL based on the data the user inputs, unfortunately I have the problem that I can only update one column at a time and sometimes none of them work. I am aware that this function is very basic and not very secure against attacks, but it is a small project that I am making. Unfortunately I only have basic programming skills so I am having trouble getting this part to work. If any help could be given it will be much appreciated.</p>
  
  <pre><code>Private Sub btnsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsave.Click
  
      Dim con As New OleDb.OleDbConnection
  
      Dim d1 As New OleDb.OleDbDataAdapter
      Dim d2 As New OleDb.OleDbDataAdapter
      Dim d3 As New OleDb.OleDbDataAdapter
      Dim d4 As New OleDb.OleDbDataAdapter
      Dim d5 As New OleDb.OleDbDataAdapter
      Dim d6 As New OleDb.OleDbDataAdapter
      Dim d7 As New OleDb.OleDbDataAdapter
      Dim d8 As New OleDb.OleDbDataAdapter
      Dim d9 As New OleDb.OleDbDataAdapter
      Dim d10 As New OleDb.OleDbDataAdapter
  
      Dim dt As New DataTable("Animals")
  
      'uses the 2010 compatible connection string
      con.ConnectionString = "PROVIDER=Microsoft.ACE.OLEDB.12.0;Data Source = h:\Animals.accdb"
      con.Open()
  
      MsgBox("UPDATE Animals SET LatinName = '" &amp; latintxt.Text &amp; "'" &amp; " WHERE AnimalName = " &amp; "'" &amp; Form1.txtname.Text &amp; "'")
      d1 = New OleDb.OleDbDataAdapter("UPDATE Animals SET LatinName = '" &amp; latintxt.Text &amp; "'" &amp; " WHERE AnimalName = " &amp; "'" &amp; Form1.txtname.Text &amp; "'", con)
      d2 = New OleDb.OleDbDataAdapter("UPDATE Animals SET LocationFound = '" &amp; locationtxt.Text &amp; "'" &amp; " WHERE AnimalName = " &amp; "'" &amp; Form1.txtname.Text &amp; "'", con)
      d3 = New OleDb.OleDbDataAdapter("UPDATE Animals SET AverageHeight = '" &amp; heighttxt.Text &amp; "'" &amp; " WHERE AnimalName = " &amp; "'" &amp; Form1.txtname.Text &amp; "'", con)
      d4 = New OleDb.OleDbDataAdapter("UPDATE Animals SET AverageWeight = '" &amp; weighttxt.Text &amp; "'" &amp; " WHERE AnimalName = " &amp; "'" &amp; Form1.txtname.Text &amp; "'", con)
      d5 = New OleDb.OleDbDataAdapter("UPDATE Animals SET DietaryNeeds = '" &amp; diettxt.Text &amp; "'" &amp; " WHERE AnimalName = " &amp; "'" &amp; Form1.txtname.Text &amp; "'", con)
      d6 = New OleDb.OleDbDataAdapter("UPDATE Animals SET ConservationStatus = '" &amp; statustxt.Text &amp; "'" &amp; " WHERE AnimalName = " &amp; "'" &amp; Form1.txtname.Text &amp; "'", con)
      d7 = New OleDb.OleDbDataAdapter("UPDATE Animals SET AverageLifeSpan = '" &amp; lifetxt.Text &amp; "'" &amp; " WHERE AnimalName = " &amp; "'" &amp; Form1.txtname.Text &amp; "'", con)
      d8 = New OleDb.OleDbDataAdapter("UPDATE Animals SET BreedingSeason = '" &amp; breedtxt.Text &amp; "'" &amp; " WHERE AnimalName = " &amp; "'" &amp; Form1.txtname.Text &amp; "'", con)
      d9 = New OleDb.OleDbDataAdapter("UPDATE Animals SET AverageLength = '" &amp; lengthtxt.Text &amp; "'" &amp; " WHERE AnimalName = " &amp; "'" &amp; Form1.txtname.Text &amp; "'", con)
      d10 = New OleDb.OleDbDataAdapter("UPDATE Animals SET AnimalName = '" &amp; nametxt.Text &amp; "'" &amp; " WHERE AnimalName = " &amp; "'" &amp; Form1.txtname.Text &amp; "'", con)
  
      d1.Fill(dt)
      d2.Fill(dt)
      d3.Fill(dt)
      d4.Fill(dt)
      d5.Fill(dt)
      d6.Fill(dt)
      d7.Fill(dt)
      d8.Fill(dt)
      d9.Fill(dt)
      d10.Fill(dt)
  
      con.Close()
  
  End Sub
  </code></pre>