473,396 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

bypass odbc connection

I have a MS Access 2007 database that contains a union query that merges 5 different odbc connections. If one connection is down I receive an 'ODBC--call failed' error and the query is unusable. Is there a way to have the database verify connection and if it cannot connect to one or more odbc, to simply by-pass the odbc(s) and use the others?
Aug 30 '11 #1
6 2513
NeoPa
32,556 Expert Mod 16PB
Test each connection first with a very simple query on each. When you know the available connections build the UNION query up from that in code.
Aug 30 '11 #2
I have 70+ users using this query on a daily basis. Most days all the connections are good. The connections are to each of my locations across the east coast. With weather and/or equipment issues there are times that one or more locations are down. I do not want to rebuild the query each time something happens.
Aug 31 '11 #3
NeoPa
32,556 Expert Mod 16PB
ChrisGia:
I do not want to rebuild the query each time something happens.
You read the bit where I suggested that is done in code right?
Aug 31 '11 #4
Hadn't caught that but now I see it. This is exactly what I want to do but have no idea how to.
Aug 31 '11 #5
NeoPa
32,556 Expert Mod 16PB
Perhaps if I laid out some pseudo-code for you that would help you develop it for your requirements
  1. Look at the SQL of the UNION query you have that covers all the various sources.
    Expand|Select|Wrap|Line Numbers
    1. SELECT *
    2. FROM   [Source1]
    3. UNION ALL
    4. SELECT *
    5. FROM   [Source2]
    6. UNION ALL
    7. SELECT *
    8. FROM   [Source3]
  2. Split up the SQL string into its various parts such that the bit that pertains to each source is kept together.
    Expand|Select|Wrap|Line Numbers
    1. str1 = "SELECT * FROM [Source1]"
    2. str2 = "SELECT * FROM [Source2]"
    3. str3 = "SELECT * FROM [Source3]"
  3. Check each source and add each string into the main SQL string, with a "UNION ALL " if, and only if, the source is good.
    Expand|Select|Wrap|Line Numbers
    1. If Source1 Is Good Then strSQL = strSQL & " UNION ALL " & str1
    2. If Source2 Is Good Then strSQL = strSQL & " UNION ALL " & str2
    3. If Source3 Is Good Then strSQL = strSQL & " UNION ALL " & str3
  4. If strSQL is empty then throw an error message or something. Don't forget to handle this possibility.
  5. Otherwise, ensure you skip the first occurrence of " UNION ALL " from the string and use it.
    Expand|Select|Wrap|Line Numbers
    1. strSQL = Mid(strSQL, 12)

Assuming Source2 is bad but all others are good then, strSQL is built up in steps :
  1. Check Source1 and add str1.
    Expand|Select|Wrap|Line Numbers
    1. " UNION ALL SELECT * FROM [Source1]"
  2. Check Source2, find it fails and do nothing with str2.
  3. Check Source3 and add str3.
    Expand|Select|Wrap|Line Numbers
    1. " UNION ALL SELECT * FROM [Source1] UNION ALL SELECT * FROM [Source3]"
  4. Strip the first occurrence of " UNION ALL ".
    Expand|Select|Wrap|Line Numbers
    1. "SELECT * FROM [Source1] UNION ALL SELECT * FROM [Source3]"
    This is equivalent to :
    Expand|Select|Wrap|Line Numbers
    1. SELECT *
    2. FROM   [Source1]
    3. UNION ALL
    4. SELECT *
    5. FROM   [Source3]"
Sep 1 '11 #6
thank you. I will give it a try.
Sep 14 '11 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: GitarJake | last post by:
Hello all, I am trying to test an ODBC connection to an Oracle dbf using the ODBC Data Source Administrator. It's not working and I suspect I haven't configured Oracle correctly. Below is...
1
by: Lyle Fairfield | last post by:
I created a new MS-SQL Database, "TestODBC". I made Table1 and StoredProcedure1. I made an ODBC DSN for that MS-SQL Database. I created a new AccessXP mdb, "TestODBC". I linked to the...
0
by: Andrew | last post by:
Hi all, I've got users with an ODBC connection to a SQL Server database. The problem is that once users get that ODBC Connection from their network administrator, they can access any table and...
5
by: Alec | last post by:
Hi All, I am currently trying to link in Access 97 to a table in a MSSQL 7 server. Initially the link is fine, however, when I close the access database and re-open it from the same network...
1
by: Zlatko Matić | last post by:
Hi! In MS Access/PostgreSQL combination I have login form. After user writes all neccessary inputs and push the button, a startup procedure creates DSN-less connection string, receates all linked...
5
by: Mike | last post by:
I am writing a .NET application in C# that uses Crystal Reports. I want the crystal reports to grab information from a database no matter where the database is located. To do this, I want to...
3
by: Greg Strong | last post by:
Hello All, Is there any way to close an ODBC connection via DSN without completely closing the Access front-end? I'm doing some testing with using Access as a front-end to Oracle 10g Express...
8
by: Greg Strong | last post by:
Hello All, The short questions are 1 Do you know how to make DSN connection close in Access to Oracle 10g Express Edition? &/or 2 Do you know how to make a DSN-less pass-through query...
3
by: zombiechewtoy | last post by:
I'm having trouble making an ODBC connection using VB.NET 2005. I have tried nearly every connection string found on connectionstrings.com, in almost every format I can think of. I have tried...
3
by: complete newbie | last post by:
Hi everyone... I need to write a VB procedure for an Excel PivotTable that will change its cached ODBC connection to a new Postgres ODBC connection. I have part of the procedure written but I do...
0
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...
0
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
0
BarryA
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...
1
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
jinu1996
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.