0
votes

I am trying to connect RStudio to MSSQL 2016 and I am getting the error message indicated in the subject line. Code is below:

install.packages("RODBC")
library(RODBC)
con < - odbcConnect("AdventureWorksDW", uid="RUser", pwd="Swim1212**")
df_adventureworks <- as.data.frame(sqlQuery(con, "select * from 
vw_FactSales"), stringsAsFactors = FALSE)
close (con)

The error messages I get are:

con < - odbcConnect("AdventureWorksDW", uid="RUser", pwd="Swim1212**")

Error: object 'con' not found

df_adventureworks <- as.data.frame(sqlQuery(con, "select * from vw_FactSales"), stringsAsFactors = FALSE)

Error in inherits(channel, "RODBC") : object 'con' not found

close (con)

Error in close(con) : object 'con' not found

1

1 Answers

1
votes

You have a typo in your object assignment. A space between the "<" and the "-", hence the "not found error":

con < - odbcConnect("AdventureWorksDW", uid="RUser", pwd="Swim1212**")

Try with this instead:

con <- odbcConnect("AdventureWorksDW", uid="RUser", pwd="Swim1212**")