MSAccess 2003 / XP / Oracle 9.2 backend
Before I get started explaining it will be helpful to see my code snipet:
-------------------------------------------
tablename = 1
On Error Resume Next
For tablename = 1 To 2
If tablename = 1 Then pdtable = "pdtable_10 1"
If tablename = 2 Then pdtable = "pdtable_11 1"
DoCmd.DeleteObj ect acTable, pdtable
Next tablename
cboSite.SetFocu s
strSite = cboSite.Text
txtUser.SetFocu s
strUser = txtUser.Text
txtPass.SetFocu s
strPass = txtPass.Text
tablename1 = 1
odbcstring = "ODBC;Driver={M icrosoft ODBC for Oracle};Server= " + strSite + ";UID=" + strUser + ";PWD=" + strPass + ""
On Error Resume Next
For tablename1 = 1 To 2
If tablename1 = 1 Then pdtable = "pdtable_10 1"
If tablename1 = 2 Then pdtable = "pdtable_11 1"
DoCmd.TransferD atabase acLink, "ODBC Database", odbcstring, _
acTable, pdtable, pdtable, 0, True
Next tablename1
------------------------------
(there are actually 11 tables that i am linking, i just cut it down for space)
I have 2 Projects:
Project1 & 2 Server: MYSERVER
Project1 UID = Ted
Project1 Pass = Williams
Project2 UID = John
Project2 Pass = Jones
-------------------------------
Problem: When I start the app for Project1 and there are no tables initailly linked, everything works fine. Then I switch to project 2 by supplying the UID and Pass and click on attach tables (which runs this code). The existing tables are deleted and the correct UID, Pass for Project2 are used. However, it links Project1 tables again. Any ideas?
9 1545
MSAccess 2003 / XP / Oracle 9.2 backend
Before I get started explaining it will be helpful to see my code snipet:
-------------------------------------------
tablename = 1
On Error Resume Next
For tablename = 1 To 2
If tablename = 1 Then pdtable = "pdtable_10 1"
If tablename = 2 Then pdtable = "pdtable_11 1"
DoCmd.DeleteObj ect acTable, pdtable
Next tablename
cboSite.SetFocu s
strSite = cboSite.Text
txtUser.SetFocu s
strUser = txtUser.Text
txtPass.SetFocu s
strPass = txtPass.Text
tablename1 = 1
odbcstring = "ODBC;Driver={M icrosoft ODBC for Oracle};Server= " + strSite + ";UID=" + strUser + ";PWD=" + strPass + ""
On Error Resume Next
For tablename1 = 1 To 2
If tablename1 = 1 Then pdtable = "pdtable_10 1"
If tablename1 = 2 Then pdtable = "pdtable_11 1"
DoCmd.TransferD atabase acLink, "ODBC Database", odbcstring, _
acTable, pdtable, pdtable, 0, True
Next tablename1
------------------------------
(there are actually 11 tables that i am linking, i just cut it down for space)
I have 2 Projects:
Project1 & 2 Server: MYSERVER
Project1 UID = Ted
Project1 Pass = Williams
Project2 UID = John
Project2 Pass = Jones
-------------------------------
Problem: When I start the app for Project1 and there are no tables initailly linked, everything works fine. Then I switch to project 2 by supplying the UID and Pass and click on attach tables (which runs this code). The existing tables are deleted and the correct UID, Pass for Project2 are used. However, it links Project1 tables again. Any ideas?
How does it know which "Project" it is running? Are you using Site for this? You will need to change the "odbcstring " depending on the project running. Are the table names the same?
Dim iProj as int
iProj = Me.txtProject
Select Case iProj
Case 1
...set the project1 variables
Case 2
...set the project2 variables
End Select
odbcstring = "ODBC;Driver={M icrosoft ODBC for Oracle};Server= " + strSite + ";UID=" + strUser + ";PWD=" + strPass + ""
If your table naming structure is as stated above you can make the following change to minimize code:
For tablename1 = 1 To 11
pdtable = "pdtable_1" & Format(tablenam e1,"000")
DoCmd.DeleteObj ect acTable, pdtable
DoCmd.TransferD atabase acLink, "ODBC Database", odbcstring, _
acTable, pdtable, pdtable, 0, True
Next tablename1
How does it know which "Project" it is running? Are you using Site for this? You will need to change the "odbcstring " depending on the project running. Are the table names the same?
Dim iProj as int
iProj = Me.txtProject
Select Case iProj
Case 1
...set the project1 variables
Case 2
...set the project2 variables
End Select
odbcstring = "ODBC;Driver={M icrosoft ODBC for Oracle};Server= " + strSite + ";UID=" + strUser + ";PWD=" + strPass + ""
If your table naming structure is as stated above you can make the following change to minimize code:
For tablename1 = 1 To 11
pdtable = "pdtable_1" & Format(tablenam e1,"000")
DoCmd.DeleteObj ect acTable, pdtable
DoCmd.TransferD atabase acLink, "ODBC Database", odbcstring, _
acTable, pdtable, pdtable, 0, True
Next tablename1
The variable strSite, strUser and strPass are from a dialog box. The username sets which set of tables are used. The terminology here is a "schema." So from my example Project1, which is the Ted schmea, it sees its own set of pdtables. Then when I log into the John schema it only sees Project2's set of pdtbales. So, when I step throught thecade as it runs, the ODBC string is correct (i.e. it is using Project2's UID and Pass). Its amost as if the first set of tables are in residual memory and, because the names are the same, it just reataches the original tables. And yes the tables names are the same.
The variable strSite, strUser and strPass are from a dialog box. The username sets which set of tables are used. The terminology here is a "schema." So from my example Project1, which is the Ted schmea, it sees its own set of pdtables. Then when I log into the John schema it only sees Project2's set of pdtbales. So, when I step throught thecade as it runs, the ODBC string is correct (i.e. it is using Project2's UID and Pass). Its amost as if the first set of tables are in residual memory and, because the names are the same, it just reataches the original tables. And yes the tables names are the same.
I notice in your connection string you are not specifying an instance or a particular database on the server. I assume "strSite" is pointing to a different server for each Project. If "strSite" is always pointing to the same server and no instance or database is specified, it will always default to the same instance or database (master in the case of SQL Server) and you will always get the same tables with your code or mine.
This is a connection string for SQL Server:
"Driver={SQLSer ver};Server=You r_Server_Name;D atabase=Your_Da tabase_Name;Uid =Your_Username; Pwd=Your_Passwo rd;"
It may be slightly different for Oracle.
FYI - You don't need to set focus on a textbox or combo to get the value in it -
Function doProject()
-
-
Dim strSite as String, strUser as String, strPass as String, tablename as int
-
strSite = Me.cboSite
-
strUser = Me.txtUser
-
strPass = Me.txtPass
-
-
odbcstring = "ODBC;Driver={Microsoft ODBC for Oracle};Server=" & strSite & ";UID=" & strUser & ";PWD=" & strPass & "
-
-
On Error Resume Next
-
-
tablename = 1
-
-
For tablename1 = 1 To 11
-
pdtable = "pdtable_1" & Format(tablename1,"000")
-
DoCmd.DeleteObject acTable, pdtable
-
DoCmd.TransferDatabase acLink, "ODBC Database", odbcstring, _
-
acTable, pdtable, pdtable, 0, True
-
Next tablename1
-
-
End Function
-
I notice in your connection string you are not specifying an instance or a particular database on the server. I assume "strSite" is pointing to a different server for each Project. If "strSite" is always pointing to the same server and no instance or database is specified, it will always default to the same instance or database (master in the case of SQL Server) and you will always get the same tables with your code or mine.
This is a connection string for SQL Server:
"Driver={SQLSer ver};Server=You r_Server_Name;D atabase=Your_Da tabase_Name;Uid =Your_Username; Pwd=Your_Passwo rd;"
It may be slightly different for Oracle.
FYI - You don't need to set focus on a textbox or combo to get the value in it -
Function doProject()
-
-
Dim strSite as String, strUser as String, strPass as String, tablename as int
-
strSite = Me.cboSite
-
strUser = Me.txtUser
-
strPass = Me.txtPass
-
-
odbcstring = "ODBC;Driver={Microsoft ODBC for Oracle};Server=" & strSite & ";UID=" & strUser & ";PWD=" & strPass & "
-
-
On Error Resume Next
-
-
tablename = 1
-
-
For tablename1 = 1 To 11
-
pdtable = "pdtable_1" & Format(tablename1,"000")
-
DoCmd.DeleteObject acTable, pdtable
-
DoCmd.TransferDatabase acLink, "ODBC Database", odbcstring, _
-
acTable, pdtable, pdtable, 0, True
-
Next tablename1
-
-
End Function
-
Thanks for the tip on not needing the setfocus. That will clean up code throughout my program.
Also, as for the reduced FOr loop, unfortunately my table numbers are sparatic (101,111,112,13 5, etc.) just happened to only include the first two tables. But thanks for that info, too.
As for the connection string, in Oracle the Server variable is the SID of the DB. In that SID I create users. Since we are going a little deeper I will tell you the actual user name is of the format pd_<project#> (e.g. pd_9500, pd_6500). So the user PD_9500 has the pdtables assgined to it. Then the user pd_6500 has its own pdtables assigned to it. The names of the pdtables are the same (e.g. pdtable101, etc.) but since they are assigned to the individual users, if I login to the DB as pd_9500, I only quer its pdtbales and the same goes for pd_6500.
So, in short, when I connect using strUser and strPass, I should be linking their respective tables, but its not.
Thanks for all the help so far.
Wouldn't it just be simpler to do all this in VBA and make the connection to your Oracle backend simply by specificing the accual user, then you wouldn't have the overhead of linking each table to the application, you just simply connect via OLEDB to your Oracle source?
If you're wanting code examples, let me know
Thanks,
Joe P.
Thanks for the tip on not needing the setfocus. That will clean up code throughout my program.
Also, as for the reduced FOr loop, unfortunately my table numbers are sparatic (101,111,112,13 5, etc.) just happened to only include the first two tables. But thanks for that info, too.
As for the connection string, in Oracle the Server variable is the SID of the DB. In that SID I create users. Since we are going a little deeper I will tell you the actual user name is of the format pd_<project#> (e.g. pd_9500, pd_6500). So the user PD_9500 has the pdtables assgined to it. Then the user pd_6500 has its own pdtables assigned to it. The names of the pdtables are the same (e.g. pdtable101, etc.) but since they are assigned to the individual users, if I login to the DB as pd_9500, I only quer its pdtbales and the same goes for pd_6500.
So, in short, when I connect using strUser and strPass, I should be linking their respective tables, but its not.
Thanks for all the help so far.
Is pd_6500 and pd_9500 logging into the same SID? A SID can have multiple databases (instances) and most likely does. I know you said each "pd" is assigned it own tables but check the "pd" defaults in Oracle security to ensure that each "pd" is not defaulting to the same database. You may have to include the database or instance name in your odbc connection string to make this work.
Wouldn't it just be simpler to do all this in VBA and make the connection to your Oracle backend simply by specificing the accual user, then you wouldn't have the overhead of linking each table to the application, you just simply connect via OLEDB to your Oracle source?
If you're wanting code examples, let me know
Thanks,
Joe P.
I am generating reports from the DB and it requires some pretty ugly joins and queries that I know how to create in access.
Is pd_6500 and pd_9500 logging into the same SID? A SID can have multiple databases (instances) and most likely does. I know you said each "pd" is assigned it own tables but check the "pd" defaults in Oracle security to ensure that each "pd" is not defaulting to the same database. You may have to include the database or instance name in your odbc connection string to make this work.
When I connect manually using a system DSN to pd_6500 the tables in the selection box appear as pd_6500.pdtable _101, etc. I tired coding this and I still get the same result. There is actaully a 3rd party CAD software that is writing to the DB so the realtionships beween tables and users have to be correct.
From the sounds of thing I may have to just use one AccessDB per project, which isnt a bad thing, just would have been nice to be able to use the one AccessDB/VBA for all projects.
When I connect manually using a system DSN to pd_6500 the tables in the selection box appear as pd_6500.pdtable _101, etc. I tired coding this and I still get the same result. There is actaully a 3rd party CAD software that is writing to the DB so the realtionships beween tables and users have to be correct.
From the sounds of thing I may have to just use one AccessDB per project, which isnt a bad thing, just would have been nice to be able to use the one AccessDB/VBA for all projects.
Normally this "pd_6500.pdtabl e_101" would indicate "database.table ".
Is pd_6500 the name of the databases as well?
Try adding the Datebase to the odbc string to ensure it's pointing to correct database.
If user name and database name are the same then use "strUser"
Dim strPD as string
strPD = Me.MyControlFor PDSelection
odbcstring = "ODBC;Driver={M icrosoft ODBC for Oracle};Server= " & strSite & ";UID=" & strUser & ";PWD=" & strPass & ";DATABASE= " & strPD & "
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: hasadh |
last post by:
I am building an application over QT. I loaded my files to a VC++
console application project.
While trying to compile my classes, I got the following set for
expcetion for all QT related classes. has anybody faced the same
issue? Plz help me out
QT version: 3.2.3
OS : Windows 2000
|
by: wmkew |
last post by:
Hello everyone
I'm encountering a R6002 Runtime error and several bugs when trying to generate a simple Managed C++ application with .NET 2003. The main problem seems to arise from linking with LIBCMT(D).DLL. (My requirement is that we can't link with MSVCRT(D).LIB.) Below are steps I've followed, and the resulting problems
1. Using the New Project wizard, generate a Visual C++ .NET Class Library project (call it "Doomed") and a VC++...
|
by: Rudy Ray Moore |
last post by:
I've been having trouble getting incremental linking to work under Visual
C++ .net 2003 7.1 for my multi-project workspace. Ronald Laeremans and Carl
Daniel (and a few others) helped me figure it out.
Short answer: I should never have expected incremental linking to work.
Short answer addendum: Linking is slower in 7.1/.net/2003 than VC++6.
===
|
by: Paolo |
last post by:
Hi all!
I have a problem with a project under VS 2005.
I downloaded 2 projects, one is a MFC .lib project and another one is
an .exe that uses this lib file. I need to edit those projects, but
first of all i tried to compile them.
Here comes the problem:
The lib proect compiles fine, but the other one says while linking:
unresolved externals! And I can't get it to work:
I tried to copy the .h and .lib files, add the paths to the...
|
by: Richard |
last post by:
First question - let's get this out of the way since it might be the
solution to all my woes: Does it make sense to have a .cpp file for a
class that is declared as having pure virtual functions in its .h file?
Here's my predicament. I'll put this in general terms since it's
happening across several classes.
I have a base class, let's say it's named A. In A.h I DECLARE several
pure virtual ( = 0) functions, a virtual destructor, and...
| |
by: ardentfreaker |
last post by:
Hi Banfa and Everybody,
This is my first post.
Well, I have a problem with a Visual Studio .NET application and was wondering if anybody could help me with figuring out the solution.
I have a Solution S in which Project A is the master project whose dependency is Project B. Project A is set to produce a DLL. Project B's output is a Static Library but is linked from a dynamic link library (DLL and LIB).
Trying to explain the same in...
|
by: Sami Lakka |
last post by:
I have a solution with a two projects. The first project contains my classes
and an executable using those classes. The second project contains unit
tests for the classes. Because the unit test framework that I use requires a
main function I have to keep the tests in a separate project. Now when I try
to link the unit test project I get a lot of "Error LNK2019: unresolved
external symbol" errors. Both projects compile just fine and and the...
|
by: Bob Palank |
last post by:
This is an issue for someone much wiser than I - perhaps a MVP will help?
I color coded the following for readability.
Running XP Pro and VC++.Net Express 2008 and vtk visualization software
In the Linker | Input ....... No additional dependencies are set
An Expected Result Follows:
------ Build started: Project: Cone041906, Configuration: Debug Win32 ------
Linking...
|
by: silverleaf |
last post by:
I'm starting to learn how to use the Allegro library with C++ on my own. My compiler is MSVisual C++ 6.0. The book I am learning out of is "Game Programming All In One, Third Edition" by Jonathan S. Harbour. I've been able to get all of the programs so far to run correctly except for the first one after setting up the compiler to statically link. I've installed the SDK for Direct X properly and the compiler has no problems linking. Yet, I...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |