I am running a query on MS Access using ODBC drivers... I understand that ODBC wants date in the QODBC format: {d 'YYYY-MM-DD'}... But still having issues.
SELECT DATEADD ("dd", -2, "{d '2022-02-02'}") AS NextCalibration FROM TblCalibItems;
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 2.
Related
I am trying to make a connection from R to Oracle and I am having issues doing so.
Here is the connection script I am using with the DBI and odbc packages:
library(DBI)
library(odbc)
con <- DBI::dbConnect(odbc::odbc(),
Driver = "Oracle in OraClient11g_home1",
Server = "orasade06.hc-sc.gc.ca",
SID = "sdv11040",
Schema = "STG",
Username = "username",
Password = "pw",
Port = 1521)
I am able to make a successful connection through Oracle SQL Developer to view my database and schema.
I have installed the Oracle ODBC driver (Oracle in OraClient11g_home1) on my machine, however I cannot make a successful connection from "R".
Here is the error I get:
Error: nanodbc/nanodbc.cpp:983: IM002: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
Any help and guidance would be greatly appreciated.
Thanks.
I have written a tutorial around this, maybe take a look :
https://guillaumepressiat.github.io/blog/2019/11/oraclyr
Some key points :
If your Oracle client is 32-bit, using R 32-bit is a (or the) solution. Otherwise R and odbc error messages aren't crystal-clear
In RStudio see if an Oracle client appears in Connections Pane
It's easier on linux but strings and parameters for odbc are a little different.
Lastly, for connection string, this answer is interesting : how to make a connection string for oracle that includes hostname, instance name, user id, password using system.data.oracleclient?
I recently upgraded from Windows 7 to Windows 10 and had to reset some remote database connections. I had previously been connecting quite successfully to an Oracle database using the Oracle 11g client and RODBC.
library(RODBC)
channel<-
odbcConnect(dsn="myoracleDB",
uid='myusername',
pw='mypassword',
believeNRows=FALSE)
result<- sqlQuery(channel,"select * from schema_name.table_name")
close(channel)
Since the Windows 10 upgrade, the above connection protocol no longer works. Specifically, I get the following error:
channel<-
odbcConnect(dsn="myoracleDB",
uid='myusername',
pw='mypassword',
believeNRows=FALSE)
Warning messages:
1: In RODBC::odbcDriverConnect("DSN=myoracleDB;UID=myusername;
PWD=mypassword",:
[RODBC] ERROR: state HY000, code 12170, message [Oracle][ODBC]
[Ora]ORA-12170: TNS:Connect timeout occurred
2: In RODBC::odbcDriverConnect("DSN=myoracleDB;UID=myusername;
PWD=mypassword",:ODBC connection failed
Two additional observations are relevant here:
I use the Windows command line to execute tnsping myoracleDB which returns a successful connection to the database
I can also use Oracle's SQL Developer Application to successfully connect to and query from the database.
So I feel confident that the Oracle Client and the ODBC Data Sources are set up correctly.
Interestingly, I AM able to connect to my database using the RODBC library if I use the following code:
mycon = odbcDriverConnect("Driver={Oracle in OraClient11g_home1};
Dbq=myoracleDB; Uid=myusername; Pwd=mypassword;",
believeNRows=FALSE)
My question for the community is:
This new connection protocol works (which I'm happy about). However, since I don't really understand why it works when the approach that worked before no longer works, I fear I may be ignoring some underlying problem that could really hurt me down the road.
I have found the following SO threads to be helpful, though neither really addresses my issue exactly:
Failure to connect to odbc database in R
Connect to ORACLE via R, using the info in sql developer
UPDATE:
I have accessed the Windows ODBC 64 bit menu and verified that I do have a DSN called "myoracleDB" which is assigned to the "Oracle in OraClient11g_home1" driver. I have tested this connection and find that it works fine. I have also used the RODBC line:
odbcDataSources()
in RStudio and found that the data source "myoracleDB" is recognized. However, when I try to execute:
channel<-
odbcConnect(dsn="myoracleDB",
uid='myusername',
pw='mypassword',
believeNRows=FALSE)
I still get the error:
"TNS: Connect timeout occurred ODBC connection failed"
If you check out the docs, DSN=myoracleDB tells RODBC to connect to the Windows DSN "myoracleDB", while Dbq=myoracleDB tells RODBC to connect to the TNSNAMES entry "myoracleDB". They're two different ways of resolving database names. tnsping and SQL Developer also both use TNSNAMES to resolve databases.
So I think your DSN probably got deleted when you reset things. You can test it by going to Control Panel > Administrative Tools > Data Sources (ODBC). If your database is there, you should be able to Configure it and click Test Connection to make sure it's working. Otherwise you can add it there, and your original configuration should work again.
I am trying to set up an .accdb as a datasource on the reporting server. The database is local on the server and I have followed all the instructions to create a 32 bit and a 64 bit ODBC connection for .mdb and .accdb. I set up the data source on the Report Manager site as ODBC with dsn=dbname and test the connection and it is successful.
From the Report Manager site, I open a report in Report Builder. I add a dataset and point to the shared connection. Test connection is successful.
I create a new data set based on this data source and click Query Designer and get this error: Unable to Connect to Datasource dbname. ERROR [IM014] [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application.
Then I prompted for credentials. Of course nothing works there. And this particular .accdb has only Admin with no password anyway. All users can access it.
The error makes me think there's a 32 bit vs 64 bit conflict. The .accdb is 32 bit, but Report Manager only sees it with the 64 bit connection, then tanks when I try to create the data set.
I've set the same odbc connections up on my local machine and on the server. Still no dice. Any and all help would be appreciated.
I kept working on this and was able to create a data source with the following connection string:
Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=\server\path\database.accdb;Uid=Admin;Pwd=;
I edited the report and used query builder to test the query and results. Query builder allows me to see results. Yay! Progress!
But now when I preview/run the report I get the following:
An error has occurred during report processing. (rsProcessingAborted)
Query execution failed for dataset 'dataset1'. (rsErrorExecutingCommand)
For more information about this error navigate to the report server on the local server machine, or enable remote errors.
Any ideas?
I was able to make this work. I had to install the 32 and 64 bit drivers on both the reporting server and the local (editing) machine. I created identical DSNs (32 bit and 64 bit) on each machine. Then set up the datasource with an OLE DB connection string.
Once complete, I was able to write reports against the database (but not browse tables). Other users could access the report from their own machines without the ODBC connections or drivers installed.
We'll call this a win. On to the next problem.
when i am linking up R and Cassandra with the RODBC library, i am getting below error
Warning messages:
1: In RODBC::odbcDriverConnect("DSN=DSN=/usr/share/cassandra/lib/cdata.jdbc.cassandra.jar")
:
[RODBC] ERROR: state IM012, code 0, message [unixODBC][Driver Manager]DRIVER keyword syntax error 2: In
RODBC::odbcDriverConnect("DSN=DSN=/usr/share/cassandra/lib/cdata.jdbc.cassandra.jar")
:
ODBC connection failed
And my code is there:
library(RODBC)
con <-odbcConnect("DSN=/usr/share/cassandra/lib/cdata.jdbc.cassandra.jar")
It looks like the problem is that you're trying to use the CData JDBC Driver with RODBC. We produce separate JDBC and ODBC drivers for Cassandra, but either will allow you access your Cassandra data in R.
You can review this article for connecting to Cassandra in R using our ODBC driver, though I've included the relevant steps below:
Configure the DSN
If you have not already, first specify connection properties in an ODBC DSN (data source name). This is the last step of the driver installation. You can use the Microsoft ODBC Data Source Administrator to create and configure ODBC DSNs.
Set the Server, Port, and Database connection properties to connect to Cassandra. Additionally, to use internal authentication set the User and Password connection properties.
Load the RODBC Package
library(RODBC)
Create a connection to your Cassandra data, using the name of the DSN you configured above
conn <- odbcConnect("CData Cassandra Source")
Once you've established the connection to your Cassandra data, you can perform all manner of operations in R, including:
Schema discovery
sqlTables(conn)
Executing SQL queries and view the results
customer <- sqlQuery(conn, "SELECT City, SUM(TotalDue) FROM Customer GROUP BY City", believeNRows=FALSE, rows_at_time=1)
View(customer)
Plot Cassandra data
par(las=2,ps=10,mar=c(5,15,4,2))
barplot(customer$TotalDue, main="Cassandra Customer", names.arg = customer$City, horiz=TRUE)
I want to connect Tableau software to my cassandra database. Note that i'm using tableau in windows7 and cassandra in ubuntu (Virtual machine).
For this i've installed the Cassandra ODBC (and Simba cassandra ODBC but i got the same problem). I got a connexion succes and i found my keyspace but not my tables !!!!!!
But no table in "cim" keyspace !!
Note that in my keyspace "cim" i have 3 tables that i can request with any problem in cassandra. Is there something i should do before creating the ODBC driver ???
Thank you for your help
The ODBC driver as it stands currently uses thrift so won't be able to communicate directly with cql3 to display the table names. Describe commands also won't work. However, you should still be able to select data from your tables. Updates to the ODBC driver should provide cql3 support at some point in the new year.
Update Simba ODBC driver for Cassandra supports CQL3 and solves your problem.
http://www.simba.com/connectors/apache-cassandra-odbc