[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Problem with odbc load and long path name

From   "Joseph Coveney" <>
To   "Statalist" <>
Subject   Re: st: Problem with odbc load and long path name
Date   Tue, 21 Oct 2008 11:40:59 +0900

Christian Meyer wrote:

I like to import data from an MSAccess database to process these data with
stata/MP 10.0 for windows. I used the following command which did not work
(error message "dsn() requiredr(198)") :

global server "W:\alle\Projekte\EARLINT\EARLINT_
odbc load, dialog(complete)dsn("Microsoft

Everything was fine if I use a shorter path with the same number of
subdirectories or if I open a stata file with "use
"$server\T0_Patienten.dta" ,clear". Removing the blank in the path did not
change anything.

Any comment is very welcome!


I can replicate your results with a dummy Microsoft Access file using your
directory path names on a local ClipDrive (32-bit Windows XP Pro SP2,
Stata  SE 10.1).

It seems that Stata's -odbc- commands have a limit for ODBC connection
string length that is shorter than Windows's.  You can see this in the
results for -odbc query- below:  Stata's error message specifically states
that the ODBC connection string is too long ("DataSourceName too long").

Until you hear back from StataCorp, you can create a DSN in Windows (the
following is for English Windows): Control Panel | Data Sources (ODBC) |
User DSN | Add | Microsoft Access-Treiber | [enter name of your choosing] |
Finish | Configure | Advanced | Options | [enter directory in Value for Type
DefaultDir] | OK | Select | Database Name | Nachbefragung_Server.mdb | OK
| OK | OK.  After setting up the DSN in Windows, you can employ that DSN
directly from Stata as shown below (I've named the DSN "Patient Follow-up"
for the illustration below).

Joseph Coveney

. version 10.1

. local dir0 F:\alle\Projekte\EARLINT

. local dir1 \EARLINT_Projekte\EARLINT_2_Projekt4

. local dir2 \Patientennachbefragung\Verwaltung

. display in smcl as result "`dir0'`dir1'`dir2'"

. local file Nachbefragung_Server

. local dsn MS Access Database;DBQ=`file';DefaultDir=`dir0'`dir1'`dir2';

. capture noisily odbc query "`dsn'"
DataSourceName too long

. odbc list

Data Source Name                   Driver
Patient Follow-up                  Microsoft Access-Treiber (*.mdb)

. set debug on

. odbc load, table(Kontaktprotokoll) dsn("Patient Follow-up") clear

[spaces inserted for clarity]

Connection Parameters (IN): DSN=Patient Follow-up;
Connection Parameters (OUT): DSN=Patient
ung\Verwaltung;DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;

. list

    |  dummy |
 1. | dummy1 |
 2. | dummy2 |
 3. | dummy3 |

. exit

end of do-file


*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index