I want to connect to DB using the iSeries Client Access driver. I use the following connection string:
DRIVER=Client Access ODBC Driver (32-bit);QUERYTIMEOUT=0;PKG=QGPL/DEFAULT(IBM),2,0,1,0,512;LANGUAGEID=ENU;DFTPKGLIB=QGPL;DBQ=QGPL
XXXXXXXX;SYSTEM=XXX.XXXXXXX.XXX;Signon=2
I get an exception when connecting:
ERROR [28000] [IBM][iSeries Access ODBC Driver]Communication link failure. comm rc=8015 - CWBSY1006 - User ID is invalid, Password length = 0, Prompt Mode = Never
How can I make the application prompt the user for his credentials to the DB?
I presume that this is a desktop application and not a server application based on the wording of the application.
If you could make use of the ODBC setup within the ODBC Data Source Administrator, that can be set to use the default setup of iSeries access.
Otherwise, you might have to prompt for the username and password within the application then pass that into the connection string.
Here's a quick example of how to make an ODBC connection to an iSeries from Excel. It'll prompt for a username and password if it doesn't already have a connection. You'll need the iSeries Navigator (aka client access) ODBC driver installed on the client.
Dim DB2Con As New ADODB.Connection
DB2Con.Properties("Prompt") = adPromptComplete
DB2Con.Open "DRIVER=Client Access ODBC Driver (32-bit);SIGNON=1;SYSTEM = YOURSYSTEMNAME"
Related
I am currently trying to connect to Snowflake via Azure AD SSO. What I would like is for the browser window to pop up so that I can put in my credentials to log me into Snowflake.
This is the code that I am currently using:
connection <- DBI::dbConnect(
drv = odbc::odbc(),
dsn = "snowflake",
server = "XXXXXXXXXXX.snowflakecomputing.com",
Trusted_Connection = "True",
authenticator = "externalbrowser"
)
A browser window does pop up, but it only has this message:
Your identity was confirmed and propagated to Snowflake ODBC driver. You can close this window now and go back where you started from.
And in my R console it says this:
Error: nanodbc/nanodbc.cpp:1021: 28000: The user you were trying to authenticate as differs from the user currently logged in at the IDP.
Where am I going wrong and how do I do this? :(
ODBC required connection parameters include the user id for the connection. As #Sergiu suggested, add the user information into the connection parameters. The user would be either yourself or whatever service account you may be using in RStudio.
Running into a odd error when trying to move a SQL connection details from R code to the DSN and using the DSN as the connection string.
Using the ODBC package, I can build a connection through RStudio using:
con <- DBI::dbConnect(odbc::odbc(),
Driver = "SQL Server Native Client 11.0",
Server = "XXX",
Database = "YYY",
uid = "username",
pwd = "password",
port = 1443)
This code above works correctly and allows the SQL connection. When moving this to the DSN (have attempted both user and system DSN) an error is generated. Both user and system DSN's have been tried and when connections are tested from the ODBC application in Windows (Win 10), the test is successful.
When using the code below in R, the connection fails.
con <- DBI::dbConnect(odbc::odbc(), "ZZZ")
Error: nanodbc/nanodbc.cpp:950: 28000: [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user ''
This would seem to indicate that the username is unknown but my information is that all of the connection parameters are stored in the DSN entry. My initial setup was generated from:
https://support.rstudio.com/hc/en-us/articles/214510788-Setting-up-R-to-connect-to-SQL-Server-
Following the further discussion at the bottom of the page, only appears to discuss the code version of the connection.
https://db.rstudio.com/databases/microsoft-sql-server/
This link discusses the DSN component as well as ensuring the driver is available.
https://db.rstudio.com/getting-started/connect-to-database
This confirms the code structure when trying to use the DSN.
I also verified this code snippet via:
https://www.r-bloggers.com/setting-up-an-odbc-connection-with-ms-sql-server-on-windows/
I attempted to use the SQL Server Driver versus the Native Client version and received the same error except the ODBC SQL Server Driver identifier instead of the Native Client 11.0. This seems to indicate that the dbconnect call is at least identifying the DSN entry.
Using the code below I confirmed that the Driver for both SQL Server and native Client 11.0 were available.
sort(unique(odbcListDrivers()[[1]]))
Add trusted connection attribute
con <- DBI::dbConnect(odbc::odbc(),
Driver = "SQL Server Native Client 11.0",
Server = "XXX",
Database = "YYY",
Trusted_Connection = "True",
uid = "username",
pwd = "password",
port = 1443)
Not sure if you're encountering the same issue, but the credentials used during DSN creation (Windows account) were different from those used in the dbConnect function call (somehow, my Microsoft account).
The user in the error message did not exist in the Security roles within SQL Server, thus not granting access to connect to the database.
Granting the user in the error message access to the required SQL server/database fixed the issue*.
CREATE LOGIN [MicrosoftAccount\xyz#outlook.com] FROM WINDOWS WITH DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english]
ALTER SERVER ROLE [sysadmin] ADD MEMBER [MicrosoftAccount\xyz#outlook.com]
* though additional security measures are advised in role creation, off-topic here.
I am trying to connect to Azure SQL Datawarehouse using RStudio. The only Authentication that is setup on the warehouse is Active Directory Password Authentication. I tried using the below connection string.
connectionString="Data Source = abc.database.secure.windows.net; Authentication=Active Directory Password;
Initial Catalog=dbo; UID='UserName';
PWD= ;
It fails with "neither DSN nor SERVER keywork supplied" . And I dont want to set up a DSN as I am building a front end app and it must be portable.
I tried RODBC too ..but couldn't get much help with Active Dir Authentication.
I finally got to the bottom of this after a few deadends. A key step is updating your ODBC driver to ODBC Driver 17. The following works using Azure Active Directory authentication, which is slightly different to a consumer key/consumer secret but may achieve the same outcome (i.e. authentication without a SQL password).
library(DBI)
server <- "yourserver.database.windows.net"
database = "database-name"
con <- DBI::dbConnect(odbc::odbc(),
UID = rstudioapi::askForPassword("username"),
Driver="ODBC Driver 17 for SQL Server",
Server = server, Database = database,
Authentication = "ActiveDirectoryInteractive")
For integrated AD authentication the connection string should look like:
Driver={ODBC Driver 13 for SQL Server};Server=tcp:{full qualified server name},1433;Database={dbname};Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;Authentication=ActiveDirectoryIntegrated
For AD passoword authentication:
Driver={ODBC Driver 13 for SQL Server};Server=tcp:{full qualified server name},1433;Database={dbname};Uid={your_user_name};Pwd={your_password_here};Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;Authentication=ActiveDirectoryPassword
Did you download the ADALSQL.DLL library https://www.microsoft.com/en-us/download/details.aspx?id=48742? required to connect to Azure AD. Also to double check the ODBC driver you use is 13.1 - correct?
If the recommendation indicated above (the ADALSQL.dll download) will not solve your problem, please create a customer case for "Azure AD authentication with SQL DB" and report it to SQL customer service.
This code works but a window appears:
library(DBI)
server <- "xxxxxxxx.database.windows.net"
database = "myDB"
con <- DBI::dbConnect(odbc::odbc(),
UID = "name#mycompany.com",
Driver="ODBC Driver 17 for SQL Server",
Server = server, Database = database,
Authentication = "ActiveDirectoryInteractive")
Firstly, I know that there are a lot of similar topics, but none seem to solve my problem.
I have inherited a project where the front-end is built in ASP.NET and the CMS is built in classic ASP. I'm in the process of setting up a local development environment where I've copied the database from the live server and am configuring the website to connect to my new local DB.
The ASP.NET part is connecting with the connection string Data Source=.\\SQLEXPRESS; Database=DBNAME; Trusted_Connection=True; but I had to mess about with Application Pools and Permissions.
I'm having a problem with getting the classic ASP part of the website to connect to the SQL database. The error I am recieving is:
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC SQL Server Driver][SQL Server]Cannot open database "DBNAME" requested by the login. The login failed.
/cms/connections/Conn.asp, line 18
The code in that file is:
12. Dim Conn_STRING, URL, mailHost
13. Conn_STRING = "Driver={SQL Server}; Server=.\SQLEXPRESS; Database=DBNAME; Trusted_Connection=True;"
15. Dim conn
16. set conn = Server.CreateObject("ADODB.Connection")
17. conn.ConnectionString = Conn_STRING
18. conn.Open
I know it's a permission problem or some sort, but I can't get to the bottom of it. I'll appreciate any help at all :)
hmmmm, well, the asp.net part is using SQLExpress, connected via an attached file. DBNAME in the first example is going to refer to a db file name in the actual asp.net project. It's been quite a long time since I last used classic ASP, but I'd be STUNNED if it supports this. You need to attach the db file to an actual sql server and use it that way.
server=mycomputername\sqlexpress; database=DBNAME; user id=username; password=password
You'll need to open your database in sql express mngmt studio
http://www.microsoft.com/download/en/details.aspx?id=7593
Go into your security settings for that user and set the default database to "dbname" (whatver your real dbname is of course)
Ensure your app pool is set to run under the user that has permissions to that database. It may just be easier to enable mixed mode authentication and create a sql user to connect to the database rather than messing around with windows authentication on an app pool.
You wil lof course need to change your connection string then to support the sql authentication if you go that route.
http://msdn.microsoft.com/en-us/library/ms143705%28v=sql.90%29.aspx
I'm writing a small ASP.NET application in a hosted environment (meaning I don't own the server).
Using the hosting provider's webtools, I created a DSN that specifies the Driver, the Server, the UID, the PWD, and the Database. When I test the connection, it tests out fine.
However, when I load my web page with the code:
OdbcConnection DB = new OdbcConnection("DSN=MyDSNName");
DB.Open();
I get the error: ERROR [28000] [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user ''.
I know I'm using the correct DSN name because when I change to "DSN=NonExistentDSN" I get a different error.
I don't understand why the logon works when I test it but not when I use it in code. Since I don't own the server, some of the usual troubleshooting tools aren't available to me, but I'd appreciate any feedback the community has.
Perhaps the DSN does not retain the password. Have you tried to supply login credentials?
OdbcConnection DB = new OdbcConnection("DSN=MyDSNName;UID=login;PWD=password;");
DB.Open();