Work has informed me that I need to run reports a certain way. I need to pull data out of the system database, and compile a report.
I have a database with 3 tables. Personel (contains employee data), Q1 (1st quarter data) and Q2 (second quarter data).
I'm trying to align the colums in the datagrid like:
Personel.EmpNumber | Personel.SS | Q1.Wages | Q2.Wages
I need all four columns as some people worked in the second quarter but not the first, and vise versa. But when I run it, only the first three columns show.
Here's my code:
Option Strict On
Public Class Form1
Dim conn As New OleDb.OleDbConnection
Dim ds As New DataSet
Dim da As New OleDb.OleDbDataAdapter
Dim sql As String
Dim strConn As String = "PROVIDER=microsoft.ace.oledb.12.0;Data Source = C:\users\fantus\documents\Database1.accdb"
Dim query As String = "SELECT Personel.AcctNum, (personel.SS1 + personel.SS2 + personel.SS3) AS SS, Q1.Q1Wages FROM Personel, Q1 WHERE q1.acctnum = personel.acctnum UNION SELECT Personel.AcctNum, (personel.SS1 + personel.SS2 + personel.SS3) AS SS, Q2.Q2Wages FROM Personel, Q2 WHERE q2.acctnum = personel.acctnum"
Dim command As New OleDb.OleDbCommand(query, conn)
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
conn.ConnectionString = strConn
conn.Open()
MsgBox(conn.State.ToString)
da.SelectCommand = command
da.Fill(ds)
Dim dt As New DataTable
da.Fill(dt)
DataGridView1.DataSource = dt
End Sub
End Class