ADODB connection error when process is called from 64-bit Excel

mediaeval

New Member
Joined
Mar 17, 2017
Messages
4
I am testing a subroutine against both 32-bit Excel 2010 and 64-bit Excel 2013. I have a cn.Open statement as follows that works for 32-bit Excel 2010, but that does not work for 64-bit Excel 2013.

Code:
 cn.Open "Driver={Microsoft Text Driver (*.txt; *.csv)};" & "Dbq=" & sFolder & ";" & "Extensions=asc,csv,tab,txt;"

When called from 64-bit Excel, it returns the error, “[ODBC Driver Manager] Data source name not found and no default driver specified”

I’ve googled this extensively and cannot find the correct code to use for 64-bit Excel 2013. Can anyone help?
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
When I use this code, with my own Dbq setting, it gives me the same error as before,

Run-time error '-2147467259 (80004005)':
[Microsoft] [ODBC Driver Manager] Data source name not found and no default driver specified
 
Upvote 0
Are you trying to make a single app for both 32 & 64? The connections are different.
Have you tried manually creating a connection in Excel, to ensure you have the correct drivers?
 
Upvote 0
I've disovered the reason why i've been getting an error with the 64-bit code, and it's very subtle. Here's the 32-bit code:

Code:
cn.Open "Driver={Microsoft Text Driver (*.txt; *.csv)};" & "Dbq=" & sFolder & ";" & "Extensions=asc,csv,tab,txt;"

Here's the 64-bit code:
Code:
cn.Open "Driver=Microsoft Access Text Driver (*.txt, *.csv); & "Dbq=" sFolder & ";" & "Extensions=asc,csv,tab,txt;"

Aside from the word Access in the 64-bit version, there is one other difference...can you spot it?

OK...it is that, in the 64-bit version, the text in the brackets, *.txt and *.csv are now separated by a comma, and not by a semi-colon, as in the 32-bit version. Agggghhhhhhh!
 
Upvote 0
One other question - is it possible to determine in code whether the calling Excel is 32-bit or 64-bit, so I could place both those versions of the code in there? Thanks!
 
Upvote 0

Forum statistics

Threads
1,215,529
Messages
6,125,343
Members
449,219
Latest member
Smiqer

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top