Help with this error.(Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘dbReadTable’ for signature ‘"Microsoft SQL Server", "missing"’ > )

I have a connection with Sql Server in which there is a table which I have to store in a data frame in R.
I am using this command

library(odbc)
library(DBI)
dbListTables(dbConn,table_name="Workdone")

(Till here it works fine.)

But,

dataset<-dbReadTable(dbConn,table_name="Workdone")

Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘dbReadTable’ for signature ‘"Microsoft SQL Server", "missing"’ >

Error pops up.

reprex::reprex({work<-dbReadTable(dbConn,table_name="Workdone")})
#> Error in dbReadTable(dbConn, table_name = "CrewDuties"): could not find function "dbReadTable"

Please help with this error.

Some discussion earlier this year that suggest;

that error indicates you need to update to the devel version of DBI

plus additional suggstions

1 Like

I found an alternative solution.
I am using
dbGetQuery() function. In which I pass SQL query and extract desired records into a data frame.
The beauty of the function is it can accept complicated SQL queries (one which are long and have many functions) and can make the query "dynamic" in shiny app by initializing input variables.
For example:-

query<-paste0("SELECT E.ShortName, E.StaffID, C.FlightDate, C.DutyCode 
From ops.CrewDuties C Inner Join Com.EMPLOYEE E On C.EmployeeID = E.EmployeeID  WHERE FlightDate between '",input$date1,"'AND '",input$date2,"'")

Crew_duties<-dbGetQuery(dbConn,query)

Thank You for the help.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.