[R] call RODBC function from DCOM

Tae Sik Han eliothan at yahoo.com
Thu Feb 3 03:46:44 CET 2005


Hi.

My VB program run a R - script located in the server
with R DCOM server. The R - script is designed to send
a query to DB through ODBC. There is NOT any problem
when I run each code from R-window interface. 

However, when I call the R-script from my VB program
it stucked after calling "sqlQuery" statement. I can
check that odbcConnect(dsn, uid, pwd) returns -1.

------------------VB code-----------------------------
        str = "setwd(" + """" + "C:/Program
Files/R/rw2001" + """" + ")"
        RLink.EvaluateNoReturn(str)
        str = "source(" + """" + "a.R" + """" + ")"
        RLink.EvaluateNoReturn(str)


------------------R script:
"a.R"-----------------------------
library(RODBC);

con = odbcConnect("dsn", uid = "...", pwd="s...");
tlist = sqlQuery(con, "select tname from cols");


------------------Error message --------------------

An unhandled exception of type
'System.Runtime.InteropServices.COMException' occurred
in MY_VB.exe

Additional information: Object is static; operation
not allowed
----------------------------------------------------

I need to do more to correctly set up DCOM server for
ODBC ?

Thanks and regards,

Eliot.




More information about the R-help mailing list