Failure to connect to odbc database in R

前端 未结 6 498
难免孤独
难免孤独 2020-12-02 00:00

I\'ve been trying to connect my company\'s DMS to R using the odbcConnect command, but get the following message:

myConn <-odbcConnect(\"NZSQ         


        
相关标签:
6条回答
  • 2020-12-02 00:05

    I ran across this same problem when I was first trying to connect to an Oracle database. In the end what worked for me was using odbcDriverConnect and a connection string instead of odbcConnect.

    myConn <-odbcDriverConnect("Driver={Oracle in OraClient11g_home1};Dbq=NZSQL;Uid=cejacobson;Pwd=password;")
    

    You can check on https://www.connectionstrings.com/ for your specific connection string for your database. Mine happened to be this one.

    Hope this helps.

    0 讨论(0)
  • 2020-12-02 00:09

    I just spent days on this. If you are using a Microsoft Access database you have to use the full path to the database, it won't even find the file in the same folder. So from the above question,

    myConn <-odbcConnect("NZSQL", uid="cejacobson", pwd="password")

    Would need to be something like

    myConn <-odbcConnect("c:\\NZSQL", uid="cejacobson", pwd="password")

    Phil's link really helped: https://www.connectionstrings.com/

    0 讨论(0)
  • 2020-12-02 00:13

    I know this is old but also make sure that you remove the spaces around the '=' sign. That was my problem.

    0 讨论(0)
  • 2020-12-02 00:13

    What worked for me was a 32 bit connection instead of a 64 bit connection.

    0 讨论(0)
  • 2020-12-02 00:17

    I was trying to access SQL Server database and got the same error. After using the correct format of db connection, I got access to my sql server database.

    dbhandle <- odbcDriverConnect("Driver={SQL Server};Server=mydbhost;Database=mydbname;Trusted_Connection=Yes")
    
    0 讨论(0)
  • 2020-12-02 00:19

    This is IM02 error which means name of the DSN is incorrect.

    GO to ODBC and check the USER/System DSN that you should be using. Once your name of DSN is correct, you might get IM014 state error which is archtecture mismatch. In that case,

    The simpler solution is IN r studio - go to tools and change the version of R to 32 bit.

    It should be ready to work

    0 讨论(0)
提交回复
热议问题