Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2522
  • Last Modified:

Creating a VBA connection string from an ODBC System DSN entry

Our DBA created the necessary ODBC entry for our database using the System DSN page.

The Connection Test passes and the one thing we needed to do was uncheck the Enable Query Timeout checkbox, which is checked by default.

Could someone please show me how to create a connection string that I can use in Excel 2007 to connect to the Oracle database with which this ODBC connection is linked?

It's an Oracle database. I am running Windows 7, and Excel 2007. The spreadsheet control is an Active X control.

In case its relevant, our DBA configured SQL Tools with that same connection and I have the following data available for each of the following fields:

UserName
Password
Bypass tnsnames.ora (checkbox is checked)
Host
TCP Port
SID
Use Service instead of SID (checkbox is checked)

Thanks!
0
newbieweb
Asked:
newbieweb
  • 6
  • 4
4 Solutions
 
newbiewebAuthor Commented:
Is this close?

Microsoft ODBC for OracleType:    ODBC Driver
Driver={Microsoft ODBC for Oracle};Server=myServerAddress;Uid=myUsername;Pwd=myPassword;

Is this a token "{Microsoft ODBC for Oracle}" ?

Or do I include this literally?

What do I use for Server?
0
 
slightwv (䄆 Netminder) Commented:
http://www.connectionstrings.com/oracle

>>What do I use for Server?

The Database alias set up in your tnsnames.ora file.  Your DBA should be able to assist you with this.
0
 
newbiewebAuthor Commented:
Thanks, I already had that link but found it confusing for the ODBC connection. My DBA gave me a sample connection string, but I am confused about how the variable "Driver" relates to Connection string?

He gave me something like this:

'Driver={Oracle in OraClient11g_home1};Data Source=OurDomain.engineering.dom;User ID=user1;Password=pw1;

How do I relate this to MyDatabase? As defined in VBA as:
Set MyDatabase = New ADODB.Connection
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
newbiewebAuthor Commented:
The Data Source Name is already defined in the ODBC connection, and it succeeds in connecting to the DB. Should I be using that?
0
 
slightwv (䄆 Netminder) Commented:
>>how the variable "Driver" relates to Connection string?

The driver specifies Who's ODBC software you are using.  In the first example you are using Micrososts.

In your latest, Oracle's.

>>and it succeeds in connecting to the DB. Should I be using that?

If you are connecting why shouldn't you use it?

>>As defined in VBA as:

My VBA is pretty rusty but you put it all together in the Open for the recordset.

There are a LOT of examples out there if you look around.

0
 
newbiewebAuthor Commented:
Your last post confuses the heck out of me.

> If you are connecting why shouldn't you use it?

I am connecting via the Test Connection in ODBC, so it seems I should use that, but this:

{Oracle in OraClient11g_home1} seems generic.

This is the Driver but in the ODBC Aministrator, there is an actual name to this entry. Should I use that instead?

> There are a LOT of examples out there if you look around.

I know, but that's part of the problem. So many, but my needs are pretty simple: connecting from Excel 2007 to an existing ODBC connection using VBA.

I need to know how to relate Driver (defined above) with the Open comand. Do you have any idea?
0
 
slightwv (䄆 Netminder) Commented:
>>{Oracle in OraClient11g_home1} seems generic.

That is just the way ODBC names the drivers.

>>there is an actual name to this entry. Should I use that instead?

I think I did steer you wrong before.  I mixed up ODBC and Native Access providers like ODP.Net and OleDb.

The 'name' is the DSN and if you want to use ODBC, that name should be used in the Server entry.  The driver should stay the same.
0
 
newbiewebAuthor Commented:
I do not need to use ODBC. I've been told it would be easier if there was no ODBC config needed on the machine where this would be deployed.

So this is fine:
{Oracle in OraClient11g_home1}

So this is right, but I do not know what to do with it:

'Driver={Oracle in OraClient11g_home1};Data Source=OurDomain.engineering.dom;User ID=user1;Password=pw1;

regarding my vaiable:
Set MyDatabase = New ADODB.Connection

Any idea?
0
 
slightwv (䄆 Netminder) Commented:
>>easier if there was no ODBC config

You will need to install and configure an Oracle Client anyway.

There are examples out there using a DSNless connection.

>>So this is fine: {Oracle in OraClient11g_home1}

If you want to use the Oracle driver, yes.

>>but I do not know what to do with it:

check out the code example in:
Problem with querying from Excel 2007 macro to Oracle.

http://www.astahost.com/info.php/Vba-Oracle_t10766.html

It uses the Microsoft driver but it should be the same for any ODBC driver.
 
0
 
newbiewebAuthor Commented:
Thanks for the help.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now