[R] sqlSave

Jacques VESLOT jacques.veslot at cirad.fr
Mon Mar 20 10:23:28 CET 2006


Dear R-users,

I tried to export a dataframe form R to Access, that way:

library(RODBC)
channel <- odbcConnectAccess("d:/test.mdb")
sqlSave(channel=channel, flore, rownames=F)
odbcClose(channel)

But I always got this error message:

Erreur dans sqlSave(channel = channel, flore, "Florist") :
[RODBC] ERROR: Could not SQLExecDirect
37000 -3553 [Microsoft][Pilote ODBC Microsoft Access] Erreur de syntaxe 
dans la définition de champ.


Note that I succeeded in exporting this dataframe into Excel and then 
import Excel file from Access.

I tried to find where the problem comes from by exporting columns one by 
one, as follows:

library(RODBC)
canal <- odbcConnectAccess("d:/test.mdb")
for (i in names(flore)) {
cat(i)
sqlSave(channel=canal, dat=flore[i]) }
odbcClose(canal)

I could export all columns but one, named "date", which consists of dates.

I tried to export this column as POSIX, as Date and even as character, 
but without success. I still had the same error message:

dateErreur dans sqlSave(channel = canal, dat = flore[i]) :
        [RODBC] ERROR: Could not SQLExecDirect
37000 -3553 [Microsoft][Pilote ODBC Microsoft Access] Erreur de syntaxe 
dans la définition de champ.

I also tried with varTypes, though I am not sure how to use this 
argument correctly. I did:

sqlSave(channel=canal, dat=flore, varTypes=c(date="Date"))
sqlSave(channel=canal, dat=flore, varTypes=c(date="Date/Heure"))

But still the same error message.

Maybe it's in Windows, but I don't understand...

Thanks for helping,

jacques

 > R.version
         _             
platform i386-pc-mingw32
arch     i386          
os       mingw32       
system   i386, mingw32 
status                 
major    2             
minor    2.1           
year     2005          
month    12            
day      20            
svn rev  36812         
language R




More information about the R-help mailing list