EDN Admin
Well-known member
Hi All,<br/>
<br/>
I have two databases. One is an SQL database and the other is an Access database.<br/>
In the Access database, I have a table with three columns EMPID, FIRSTNAME and LASTNAME.<br/>
I load this in my VB program to a table called "EMPID_Table"<br/>
<br/>
In the SQL database, there is a table that has a lot of data that I need to retrieve
<br/>
based on the Employee#, which is the same as the EMPID from the Access database. In my
<br/>
VB program this is loaded into a table called "WagesTable"<br/>
<br/>
How can I merge these tables, or add the columns FIRSTNAME and LASTNAME to the WagesTable<br/>
to the correct Employee# in my VB program? I cannot change the SQL database at all, I
<br/>
can only read from it.
Access Query:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Dim EMPID_Query <span style="color:Blue; As <span style="color:Blue; String = _
<span style="color:#A31515; "SELECT *" & <span style="color:#A31515; "FROM [EMPID_Table]"
<span style="color:Green; This returns EMPID, FIRSTNAME and LASTNAME
<span style="color:Green; I fill this to a table called "EMPID_Table"
[/code]
SQL Query:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Dim Wages_Query <span style="color:Blue; As <span style="color:Blue; String = _
<span style="color:#A31515; "SELECT [Employee#], [Operation_Num], SUM(STHrs) as [STHrs], SUM(OTHrs) as [OTHrs], SUM(OTWag) as [OTWag]," & _
<span style="color:#A31515; " SUM(Shift_Diff) as [Shift_Diff]," & _
<span style="color:#A31515; " SUM(COALESCE(STHrs,0) + COALESCE(OTHrs,0)) as [TotalHours]," & _
<span style="color:#A31515; " SUM(COALESCE(STWag,0) + COALESCE(OTWag,0) + COALESCE(Shift_Diff,0)) as [TotalWages]" & _
<span style="color:#A31515; " FROM dbo.Financial" & _
<span style="color:#A31515; " WHERE Employee# = ? AND [Operation_Num] IN (301, 302, 303, 304, 305, 306, 307, 308, 310)" & _
<span style="color:#A31515; " AND [Date_Work] BETWEEN StartDate AND EndDate" & _
<span style="color:#A31515; " GROUP BY [Employee#], [Operation_Num]"
<span style="color:Green; This returns a lot of information and is filled to a table called "WagesTable"
[/code]
Any help is greatly appreciated!<br/>
-Diana
View the full article
<br/>
I have two databases. One is an SQL database and the other is an Access database.<br/>
In the Access database, I have a table with three columns EMPID, FIRSTNAME and LASTNAME.<br/>
I load this in my VB program to a table called "EMPID_Table"<br/>
<br/>
In the SQL database, there is a table that has a lot of data that I need to retrieve
<br/>
based on the Employee#, which is the same as the EMPID from the Access database. In my
<br/>
VB program this is loaded into a table called "WagesTable"<br/>
<br/>
How can I merge these tables, or add the columns FIRSTNAME and LASTNAME to the WagesTable<br/>
to the correct Employee# in my VB program? I cannot change the SQL database at all, I
<br/>
can only read from it.
Access Query:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Dim EMPID_Query <span style="color:Blue; As <span style="color:Blue; String = _
<span style="color:#A31515; "SELECT *" & <span style="color:#A31515; "FROM [EMPID_Table]"
<span style="color:Green; This returns EMPID, FIRSTNAME and LASTNAME
<span style="color:Green; I fill this to a table called "EMPID_Table"
[/code]
SQL Query:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Dim Wages_Query <span style="color:Blue; As <span style="color:Blue; String = _
<span style="color:#A31515; "SELECT [Employee#], [Operation_Num], SUM(STHrs) as [STHrs], SUM(OTHrs) as [OTHrs], SUM(OTWag) as [OTWag]," & _
<span style="color:#A31515; " SUM(Shift_Diff) as [Shift_Diff]," & _
<span style="color:#A31515; " SUM(COALESCE(STHrs,0) + COALESCE(OTHrs,0)) as [TotalHours]," & _
<span style="color:#A31515; " SUM(COALESCE(STWag,0) + COALESCE(OTWag,0) + COALESCE(Shift_Diff,0)) as [TotalWages]" & _
<span style="color:#A31515; " FROM dbo.Financial" & _
<span style="color:#A31515; " WHERE Employee# = ? AND [Operation_Num] IN (301, 302, 303, 304, 305, 306, 307, 308, 310)" & _
<span style="color:#A31515; " AND [Date_Work] BETWEEN StartDate AND EndDate" & _
<span style="color:#A31515; " GROUP BY [Employee#], [Operation_Num]"
<span style="color:Green; This returns a lot of information and is filled to a table called "WagesTable"
[/code]
Any help is greatly appreciated!<br/>
-Diana
View the full article