title: vb.net and sql query
body: <p>I am new to vb.net  so bear with me. I have some managable tables in ms access database. I am trying to write a sql query that will give me following output:</p>
  
  <pre>
  table1 ( columnA - columnB)
  table2 ( columnA - columnB)
  table3 ( columnA - columnB)
  </pre>
  
  <p>I have column name "column A" and “column B" in all tables.</p>
  
  <p>I want to retrieve tables name and sum of (column A – column B) of all tables. When I run the sql statement I get the following error:</p>
  
  <blockquote>
    <p>The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect</p>
  </blockquote>
  
  <p>Can someone help me to write a sql query please?</p>
  
  <p>Here is my full code:</p>
  
  <pre class="lang-vb prettyprint-override"><code>Dim con As New OleDbConnection(" Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\msacc.accdb")   
  
  Dim Query2 As String = " SELECT Table1 AS Table, SUM(a) - SUM(b) AS Result FROM table1 UNION  SELECT Table2, SUM(a) - SUM(b) FROM table2  UNION SELECT Table3, SUM(a) - SUM(b) FROM table3"
  Dim Da As OleDbDataAdapter, Ds As New DataSet, Dtb As New System.Data.DataTable
  con.Open()
  Da = New OleDbDataAdapter(Query2, con)
  Da.Fill(Ds)
  con.Close()
  Dtb = Ds.Tables(0)
  DataGridView1.DataSource = Dtb
  </code></pre>