Help,
im trying to use a union join from an SQL database and a Access database -
the program works fine from my own machine as i have the odbc DSN
connections setup
from access to link to the SQL tables.
i need to set this up in code to connect to both databases and do my union
join but i have no idea how to
below is my current code (using the DSN connection):
Dim strConnect As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=\\Gringotts\Common Documents\Master Database\OwnAndSave.mdb;" &
_
"Persist Security Info=False"
Dim RowCount As Integer = 0
Dim ocon1 As OleDbConnection = New OleDbConnection(strConnect)
ocon1.Open()
Dim ds1 As DataSet = New DataSet()
Dim da1 As OleDbDataAdapter = New OleDbDataAdapter()
da1.SelectCommand = New OleDbCommand("SELECT Personal.ID, Personal.Surname1,
Personal.Postcode, Personal.Town, LiveTracker.SalesAppointment,
LiveTracker.SalesManager FROM (Personal LEFT JOIN LiveTracker ON Personal.ID
= LiveTracker.ID) LEFT JOIN Closed ON Personal.ID = Closed.ID WHERE
(((LiveTracker.SalesAppointment) Between Date() And Date()+28) AND
((LiveTracker.PostalPackReturned)=#1/1/1900#) AND ((Closed.ID) Is Null))
UNION SELECT dbo_Personal.ID, dbo_Personal.surname1, dbo_Personal.postcode1,
dbo_Personal.town1, dbo_LiveTracker.SalesAppointment,
dbo_LiveTracker.SalesManager FROM (dbo_Personal INNER JOIN dbo_LiveTracker
ON dbo_Personal.ID = dbo_LiveTracker.ID) LEFT JOIN dbo_Closed ON
dbo_Personal.ID = dbo_Closed.ID WHERE
(((dbo_LiveTracker.SalesAppointment)>Date()) AND
((dbo_LiveTracker.PostalPackReturned)=#1/1/1900#) AND ((dbo_Closed.ID) Is
Null));", ocon1)
da1.Fill(ds1)
any help would be greatly appreciated
Thanks
Mike Fellows 3 2448
Hi Mike,
I think a Join question is typical a question for Miha, the two Bills, Kevin
or others who are often active in the newsgroup
Adonet
<news://msnews.microsoft.com/microsoft.public.dotnet.framework.adonet>
Web interface:
< http://communities2.microsoft.com/co...s/?dg=microsof
t.public.dotnet.framework.adonet>
I thought that there is a bug with the Join in OleDb with an access
database.
However try it in the adonet group, although a lot of us know the answer I
think, I think there you have a better change.
Cor
Hi,
Here is a similar stored procedure I used. Maybe this will help
ALTER Procedure ByCategory
@Start DateTime,
@Finish DateTime
AS Select PriceCategory.CategoryName,
SUM(InvoiceData.Each) as TotalPrice
From ((InvoiceData Inner Join Invoices ON Invoices.InvoiceID =
InvoiceData.InvoiceID)
Inner Join PriceList ON PriceList.Description LIKE InvoiceData.Description)
Inner Join PriceCategory ON PriceList.Category = PriceCategory.CategoryID
Where Invoices.BillDate > @Start AND Invoices.BillDate < @Finish
Group by PriceCategory.CategoryName
Ken
----------------------------
"Mike Fellows" <mi***************@equityhouse.co.uk> wrote in message
news:EK***********@newsfe2-gui.server.ntli.net... Help,
im trying to use a union join from an SQL database and a Access database - the program works fine from my own machine as i have the odbc DSN connections setup from access to link to the SQL tables.
i need to set this up in code to connect to both databases and do my union join but i have no idea how to
below is my current code (using the DSN connection):
Dim strConnect As String = _ "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=\\Gringotts\Common Documents\Master Database\OwnAndSave.mdb;" & _ "Persist Security Info=False" Dim RowCount As Integer = 0
Dim ocon1 As OleDbConnection = New OleDbConnection(strConnect) ocon1.Open() Dim ds1 As DataSet = New DataSet() Dim da1 As OleDbDataAdapter = New OleDbDataAdapter() da1.SelectCommand = New OleDbCommand("SELECT Personal.ID, Personal.Surname1, Personal.Postcode, Personal.Town, LiveTracker.SalesAppointment, LiveTracker.SalesManager FROM (Personal LEFT JOIN LiveTracker ON Personal.ID = LiveTracker.ID) LEFT JOIN Closed ON Personal.ID = Closed.ID WHERE (((LiveTracker.SalesAppointment) Between Date() And Date()+28) AND ((LiveTracker.PostalPackReturned)=#1/1/1900#) AND ((Closed.ID) Is Null)) UNION SELECT dbo_Personal.ID, dbo_Personal.surname1, dbo_Personal.postcode1, dbo_Personal.town1, dbo_LiveTracker.SalesAppointment, dbo_LiveTracker.SalesManager FROM (dbo_Personal INNER JOIN dbo_LiveTracker ON dbo_Personal.ID = dbo_LiveTracker.ID) LEFT JOIN dbo_Closed ON dbo_Personal.ID = dbo_Closed.ID WHERE (((dbo_LiveTracker.SalesAppointment)>Date()) AND ((dbo_LiveTracker.PostalPackReturned)=#1/1/1900#) AND ((dbo_Closed.ID) Is Null));", ocon1) da1.Fill(ds1)
any help would be greatly appreciated
Thanks
Mike Fellows
the SQL Side is not a problem i can easily create the stored procedure
i can also get the data from access easily
its gettign it from both at the same time which i am having problems with
( i need them in a single sorted dataset)
Mike
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:Oe**************@tk2msftngp13.phx.gbl... Hi,
Here is a similar stored procedure I used. Maybe this will help
ALTER Procedure ByCategory @Start DateTime, @Finish DateTime AS Select PriceCategory.CategoryName, SUM(InvoiceData.Each) as TotalPrice From ((InvoiceData Inner Join Invoices ON Invoices.InvoiceID = InvoiceData.InvoiceID) Inner Join PriceList ON PriceList.Description LIKE
InvoiceData.Description) Inner Join PriceCategory ON PriceList.Category = PriceCategory.CategoryID Where Invoices.BillDate > @Start AND Invoices.BillDate < @Finish Group by PriceCategory.CategoryName
Ken ---------------------------- "Mike Fellows" <mi***************@equityhouse.co.uk> wrote in message news:EK***********@newsfe2-gui.server.ntli.net... Help,
im trying to use a union join from an SQL database and a Access
database - the program works fine from my own machine as i have the odbc DSN connections setup from access to link to the SQL tables.
i need to set this up in code to connect to both databases and do my
union join but i have no idea how to
below is my current code (using the DSN connection):
Dim strConnect As String = _ "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=\\Gringotts\Common Documents\Master
Database\OwnAndSave.mdb;" & _ "Persist Security Info=False" Dim RowCount As Integer = 0
Dim ocon1 As OleDbConnection = New OleDbConnection(strConnect) ocon1.Open() Dim ds1 As DataSet = New DataSet() Dim da1 As OleDbDataAdapter = New OleDbDataAdapter() da1.SelectCommand = New OleDbCommand("SELECT Personal.ID, Personal.Surname1, Personal.Postcode, Personal.Town, LiveTracker.SalesAppointment, LiveTracker.SalesManager FROM (Personal LEFT JOIN LiveTracker ON Personal.ID = LiveTracker.ID) LEFT JOIN Closed ON Personal.ID = Closed.ID WHERE (((LiveTracker.SalesAppointment) Between Date() And Date()+28) AND ((LiveTracker.PostalPackReturned)=#1/1/1900#) AND ((Closed.ID) Is Null)) UNION SELECT dbo_Personal.ID, dbo_Personal.surname1, dbo_Personal.postcode1, dbo_Personal.town1, dbo_LiveTracker.SalesAppointment, dbo_LiveTracker.SalesManager FROM (dbo_Personal INNER JOIN
dbo_LiveTracker ON dbo_Personal.ID = dbo_LiveTracker.ID) LEFT JOIN dbo_Closed ON dbo_Personal.ID = dbo_Closed.ID WHERE (((dbo_LiveTracker.SalesAppointment)>Date()) AND ((dbo_LiveTracker.PostalPackReturned)=#1/1/1900#) AND ((dbo_Closed.ID)
Is Null));", ocon1) da1.Fill(ds1)
any help would be greatly appreciated
Thanks
Mike Fellows
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: News |
last post by:
Folks,
I need help with this task. I have a set of data that needs to be plotted on
timeline chart.
Example:
Unit ProcStart ProcEnd Machine
U1 5/5/03 6:01 5/5/03 6:04 M1
U2 ...
|
by: OBJECT MODULE, INC. |
last post by:
table 1
APP_ID
1
3
table 2
|
by: Yannick Turgeon |
last post by:
Hello all,
I'm using SS 2000 and NT4.
Say I've got three tables: T1, T2 and T3. T3 contains the 1-to-multiple data
of the relation between T1 and T2:
...
|
by: stu_gots |
last post by:
I have been losing sleep over this puzzle, and I'm convinced my train
of thought is heading in the wrong direction. It is difficult to
explain my circumstances, so I will present an identical...
|
by: Sebastian |
last post by:
The following query needs about 2 minutes to complete (finding dupes)
on a table of about 10000 addresses. Does anyone have an idea on how
to speed this up ?
Thanks in advance !!!
Sebastian
|
by: joshnosh |
last post by:
I have two tables tblLogin and tblTrades
I have 3 fields in each table, for thr purpose of this question
tblLogin Fields are
MemberNo
RegNo
Country
tblTrades fields are
|
by: Dom Boyce |
last post by:
Hi
First up, I am using MS Access 2002.
I have a database which records analyst rating changes for a list of
companies on a daily basis. Unfortunately, the database has been set
up (by my...
|
by: mutemode |
last post by:
I have this query
SELECT 'bracket' = CASE
WHEN income BETWEEN 0 AND 49 THEN '0-49'
WHEN income BETWEEN 50 AND 99 THEN '50-99'
WHEN income BETWEEN 100 AND 499 THEN '100-499'
WHEN income BETWEEN...
|
by: LanaR |
last post by:
Hello,
one sql statement is causing severe performance issue. The problem occurs only in UDB environment, the same statemnt on the mainframe is running fine. I have an explain output from the sql....
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |