hsOpenDb | R Documentation |
Opens database connection to MS Access or MS Excel, checks the connection and stops on error.
hsOpenDb(src, use2007Driver = NULL, dbg = FALSE, DBMSencoding = "", ...)
src |
full path to MS Access database file (extension “.mdb” or “.accdb”) or MS Excel file (extension “.xls” or “.xlsx”) or name of ODBC data source. |
use2007Driver |
if TRUE the functions odbcConnectAccess2007 and odbcConnectExcel2007 are used instead of odbcConnectAccess and odbcConnectExcel, respectively |
dbg |
if TRUE and if the connection could be established details of the connection are shown. |
DBMSencoding |
finally passed to |
... |
additional arguments passed to the odbcConnect...()-function |
On success an object of class RODBC describing the connection is returned. On failure nothing is returned and program execution stops.
hsCloseDb
## Not run:
## Open a connection to the example database
## (only on Windows!)
if (.Platform$OS.type == "windows") {
con <- hsOpenDb(xmdb())
con
}
## Details on the established connection are shown:
# RODBC Connection 9
# Details:
# case=nochange
# DBQ=C:\Users\hsonne\Documents\R\win-library\2.14\kwb.base\...
# Driver={Microsoft Access Driver (*.mdb)}
# DriverId=25
# FIL=MS Access
# MaxBufferSize=2048
# PageTimeout=5
# UID=admin
## Close the connection again
if (.Platform$OS.type == "windows") {
hsCloseDb(con)
}
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.