Hi, I want to import some data from Access and I am using the following codes: testdb <- file.path("c/../db1") channel <- odbcConnect("testdb") sqlFetch(channel,"tbl",colnames = TRUE, rownames = FALSE) It comes out the error message: 1: [RODBC] ERROR: state IM002, code 0, message [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified 2: ODBC connection failed in: odbcDriverConnect(st, ...) Anyone can help me sort it out? Many thanks. -- View this message in context: http://www.nabble.com/Import--data-from-Access-tf3847342.html#a10896743 Sent from the R help mailing list archive at Nabble.com.
You need to do 1 of 2 things (but not both). Either register your database file with your odbc driver (done outside of R) Or Use odbcConnectAccess in place of odbcConnect The 2nd is simpler if you just want to import that file, the first may be better in the long run if you are going to be working with the database quite a bit. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at intermountainmail.org (801) 408-8111> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of livia > Sent: Thursday, May 31, 2007 9:55 AM > To: r-help at stat.math.ethz.ch > Subject: [R] Import data from Access > > > Hi, I want to import some data from Access and I am using the > following > codes: > > testdb <- file.path("c/../db1") > channel <- odbcConnect("testdb") > sqlFetch(channel,"tbl",colnames = TRUE, rownames = FALSE) > > It comes out the error message: > > 1: [RODBC] ERROR: state IM002, code 0, message > [Microsoft][ODBC Driver Manager] Data source name not found > and no default driver specified > 2: ODBC connection failed in: odbcDriverConnect(st, ...) > > Anyone can help me sort it out? Many thanks. > > -- > View this message in context: > http://www.nabble.com/Import--data-from-Access-tf3847342.html# > a10896743 > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
library(RODBC); mdbConnect <- odbcConnectAccess("C:\\db.mdb"); data <- sqlFetch(mdbConnect, "tblData"); odbcClose(mdbConnect); On 5/31/07, livia <yn19832@msn.com> wrote:> > > Hi, I want to import some data from Access and I am using the following > codes: > > testdb <- file.path("c/../db1") > channel <- odbcConnect("testdb") > sqlFetch(channel,"tbl",colnames = TRUE, rownames = FALSE) > > It comes out the error message: > > 1: [RODBC] ERROR: state IM002, code 0, message [Microsoft][ODBC Driver > Manager] Data source name not found and no default driver specified > 2: ODBC connection failed in: odbcDriverConnect(st, ...) > > Anyone can help me sort it out? Many thanks. > > -- > View this message in context: > http://www.nabble.com/Import--data-from-Access-tf3847342.html#a10896743 > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- WenSui Liu A lousy statistician who happens to know a little programming (http://spaces.msn.com/statcompute/blog) [[alternative HTML version deleted]]