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_
Projekte\EARLINT_2_Projekt4\Patientennachbefragung\Verwaltung"
odbc load, dialog(complete)dsn("Microsoft
Access-Datenbank;DBQ=$server\Nachbefragung_Server.mdb")table("Kontaktprotoko
ll")clear
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'"
F:\alle\Projekte\EARLINT\EARLINT_Projekte\EARLINT_2_Projekt4\Patientennachbefragung\Verwal
tung
. 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
-------------------------------------------------------------------------------
[snip]
Patient Follow-up Microsoft Access-Treiber (*.mdb)
[snip]
-------------------------------------------------------------------------------
. 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
Follow-up;DBQ=F:\alle\Projekte\EARLINT\EARLINT_Pr
ojekte\EARLINT_2_Projekt4\Patientennachbefragung\Verwaltung\Nachbefragung_Server.mdb;Def
aultDir=F:\alle\Projekte\EARLINT\EARLINT_Projekte\EARLINT_2_Projekt4\Patientennachbefrag
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:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/