473,714 Members | 2,562 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Connecting to ODBC DB at startup

RLN
RE: Access 2003 using WinXP SP2

Problem: When I start up my app I double click either one of my two
Oracle tables in the table list, it asks for an id and pass. I need
them to be linked at startup automatically.

The Oracle db contains two tables I need.
I've already created an ODBC data source that contains the userid and
pass to link to the Oracle DB. It works.
When I go into linked table manager, I can link to them just fine
manually.
When the applications starts up I have a VBA module that runs when the
apps starts up. It simply connects to the Oracle database and does a
'select *' from one of the tables I need and returns the right value
from the recordset. Runs great.

The problem is when I go to run a query or do anything else in the app
later against either of these two Oracle tables, Access asks for a
userid and pass as though I am not connected to it. I thought that I
still had a good connection when the app started up. I did not close
the initial connection object when the app started up.

I'm thinking of as possible solution here as I type... is there a way to
do the following in VBA:
-bring up linked table manager
-select "ODBC databases"
-select my data source
-login
-find the two tables and link them to the db.
(all of this has to be done manually right now even though I was able to
get a good connection when the app launched.)

Any ideas on what I might be able to do here?
Thanks.

FWIW: Here is my initial connection function that runs at startup:

<begin code>
Public Function OracleConnect_F XP()

Dim cnConn As ADODB.Connectio n
Dim rsTemp As ADODB.Recordset
Dim strDB As String
Dim strLogin As String
Dim strTable As String
Dim strMsg As String
Dim strSQL As String
Dim strPass As String

strDB = "MyDB"
strLogin = "MyLogin"
strPass = "MyPass"
strTable = "MyTable"

Set rsTemp = New ADODB.Recordset
Set cnConn = New ADODB.Connectio n

'Using Microsoft Oracle driver
cnConn.Connecti onString = "Provider=MSDAO RA;" & "Password=" & strPass &
"; User ID=" & strLogin & ";Data Source=" & strDB & "; Persist Security
Info=True"
cnConn.CursorLo cation = adUseClient
cnConn.Open
strSQL = "SELECT Count(*) as results FROM " & strTable
rsTemp.Open "SELECT Count(*) as results FROM " &
strTable, cnConn, adOpenStatic, adLockReadOnly

'yields 1 row when doing a Select Count(*)
'yieldss '98' rows when doing a Select *"
strMsg = strMsg & vbCrLf & strDB & "/" & strLogin & "/" & strPass &
vbCrLf & _
"Select (*) Count--rsTemp.Recordco unt: " & rsTemp.RecordCo unt & vbCrLf &
"Select (*) Count--rsTemp!Results: " & rsTemp!Results & "Connection
String: " & cnConn.Connecti onString

MsgBox strMsg, vbOKOnly, "RLNTest-DB Connection"

End Function

<end code>

----------
"Perseveran ce - there is no substitute for hard work."
- Thomas Alva Edison

*** Sent via Developersdex http://www.developersdex.com ***
Mar 8 '06 #1
1 3805
Creating an Oracle connection in an independent object
won't help your Access object at all. The code below
is irrelevant for linked tables.

Creating an Oracle connection in an independent object
won't help an other objects you create later. If you
want to maintain the object you have created, you need
a static object or an object with global scope.

The object in the code below does not seem to use
an ODBC DSN at all (I may have misread it). Putting
a user name and password into a DSN won't help if
you don't use the DSN.

Are you using ODBC? Are you using linked tables?
If so, what is the connect string for the linked
tables? Did you use the DSN when you created
the linked tables? Did you save the password when
you created the linked tables?

(david)

"RLN" <no****@devdex. com> wrote in message
news:X0******** *******@news.us west.net...
RE: Access 2003 using WinXP SP2

Problem: When I start up my app I double click either one of my two
Oracle tables in the table list, it asks for an id and pass. I need
them to be linked at startup automatically.

The Oracle db contains two tables I need.
I've already created an ODBC data source that contains the userid and
pass to link to the Oracle DB. It works.
When I go into linked table manager, I can link to them just fine
manually.
When the applications starts up I have a VBA module that runs when the
apps starts up. It simply connects to the Oracle database and does a
'select *' from one of the tables I need and returns the right value
from the recordset. Runs great.

The problem is when I go to run a query or do anything else in the app
later against either of these two Oracle tables, Access asks for a
userid and pass as though I am not connected to it. I thought that I
still had a good connection when the app started up. I did not close
the initial connection object when the app started up.

I'm thinking of as possible solution here as I type... is there a way to
do the following in VBA:
-bring up linked table manager
-select "ODBC databases"
-select my data source
-login
-find the two tables and link them to the db.
(all of this has to be done manually right now even though I was able to
get a good connection when the app launched.)

Any ideas on what I might be able to do here?
Thanks.

FWIW: Here is my initial connection function that runs at startup:

<begin code>
Public Function OracleConnect_F XP()

Dim cnConn As ADODB.Connectio n
Dim rsTemp As ADODB.Recordset
Dim strDB As String
Dim strLogin As String
Dim strTable As String
Dim strMsg As String
Dim strSQL As String
Dim strPass As String

strDB = "MyDB"
strLogin = "MyLogin"
strPass = "MyPass"
strTable = "MyTable"

Set rsTemp = New ADODB.Recordset
Set cnConn = New ADODB.Connectio n

'Using Microsoft Oracle driver
cnConn.Connecti onString = "Provider=MSDAO RA;" & "Password=" & strPass &
"; User ID=" & strLogin & ";Data Source=" & strDB & "; Persist Security
Info=True"
cnConn.CursorLo cation = adUseClient
cnConn.Open
strSQL = "SELECT Count(*) as results FROM " & strTable
rsTemp.Open "SELECT Count(*) as results FROM " &
strTable, cnConn, adOpenStatic, adLockReadOnly

'yields 1 row when doing a Select Count(*)
'yieldss '98' rows when doing a Select *"
strMsg = strMsg & vbCrLf & strDB & "/" & strLogin & "/" & strPass &
vbCrLf & _
"Select (*) Count--rsTemp.Recordco unt: " & rsTemp.RecordCo unt & vbCrLf &
"Select (*) Count--rsTemp!Results: " & rsTemp!Results & "Connection
String: " & cnConn.Connecti onString

MsgBox strMsg, vbOKOnly, "RLNTest-DB Connection"

End Function

<end code>

----------
"Perseveran ce - there is no substitute for hard work."
- Thomas Alva Edison

*** Sent via Developersdex http://www.developersdex.com ***

Mar 9 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1386
by: Kong Li | last post by:
Follow up to this thread, the latest Oracle 9i release 2 patchset (9.2.0.5) fixed the handle count leak problem. The problem is in Oracle client component. Thanks. Kong ----- From: Kong Li (likong@email.com)
3
1409
by: nzanella | last post by:
Hello, I have MS SQL Server running on a server computer. I am trying to connect to it via ASP from a .asp file created in a virtual directory. I am using IIS as the web server. I am connecting from a Windows 2000 computer. When I go to Start -> Settings -> Control Panel -> Administrative Tools -> ODBC Data Sources
3
2392
by: Bob | last post by:
All, I have read through lots of postings regarding my concerns, but I haven't found what I am looking for. The center (non profit University) where I work collects scientific data about subjects enrolled in studies related to respiratory diseases. Both lab data and questionnaire information are collected. We use W2K as PC operating systems, MS Access XP, XP Developer, and Visual SourceSafe. Our databases use a front end – back end...
1
1567
by: Kavvy | last post by:
I'm working on a Win app and in the Data tab there are only classes for OleDB and Sql. I create an OleDB (Using the Microsoft OLE DB Provider for ODBC) connection to my Access DB, but it throws the following error when I try to actually drag a table onto the form. "You cannot use a OLE DB provider for ODBC drivers" Any ideas on what might be wrong?
3
2242
by: Jeremy Dillinger | last post by:
I am trying to design a program that will use data from a MySQL database. Currently all the data is being used with PHP scripts from a website. I am also trying to build a software solution that can use the same data. I have gone through all the data connectors in Visual Basic.net and none of them have the options for connecting to MySQL. Does anybody know how I would go about doing this? Thanks in advance! Jeremy
3
2702
by: Paradox Synthesist | last post by:
hi, i am a newbie to asp.net and have started learning mainly from websites. i have a question which IS very silly and trivial. http://msdn2.microsoft.com/en-us/library/system.data.odbc.odbcconnectionstringbuilder.dsn(VS.80).aspx i looked through this url to see how could i connect to a mysql database...where does the dsn figure out? why do i need to give it? i cant see any dsn specified anywhere on the database control panel. i am a...
5
3418
by: WPW07 | last post by:
Hello, I've installed the ODBC connector for MySQL and can go into Access and manually link to the MySQL tables. Everything works fine this way. But rather than go into the Windows Data Source Adminstrator on each user's computer, how would you code an MS Access front end to connect to MySQL tables at startup? Where would you put the code and how would you call it when the Access database is opened?
2
3068
by: franc sutherland | last post by:
Hi, I am trying to build a database in Access 2003 which can connect to information in a SAGE system. Should I use ODBC, and if so, which driver is required? Is there another way of connecting? Which is best? Thanks, Franc.
8
1795
by: Daveo | last post by:
Dear all, We recently migrated a SQL database from one server to another. Now, when you try to run some code in an Access Database which links to the SQL one, you get a 3704 error "Operation is not allowed when the object is closed". I think this means that the connection between the Access DB and SQL Server has not been made. - The IP address of the new server is the same as the old one and the host file on the client PCs has been...
0
8796
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, 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...
0
9307
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9170
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 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...
1
9071
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,...
0
7946
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, 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...
1
6627
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5943
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();...
1
3155
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
3
2105
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.