Background:
I am using Windows 10 and Perl v5.26.1. I inherited some Perl code that needs to connect to a database. This previously worked using Windows 7 and Perl 5.16.3.
The code is using Win32::ODBC to connect to the database. I get the following error:
Connect failed: [911] [] "[Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application"
I am using a 64 bit version of Perl and trying to connect to a 32 bit MS Access database but I am assuming that Win32 is handling this. Also the same setup was working in the Windows 7 setup.
I am able to connect to the database using the ODBC Data Source Administrator.
As an attempt to determine the issue I tried:
use strict;
use Win32::ODBC;
print "DataSources\n";
my (%dsn, $key) = Win32::ODBC::DataSources();
foreach $key (sort keys %dsn) {
print "$key\n";
}
print "Done\n";
This resulted in
DataSources
Done
So I am not finding any DataSources. Running the same code on the Windows 7 machine does generate DataSources.
Running Get-OdbcDsn in Powershell generates a list of data sources.
Question:
Why am I not able to see DataSources using Perl in v5.26.1 using Windows 10?
Related
I need a simple ODBC test scenario on WIN which I can configure very simply and be assured it is working in support of another question at Unix.SE.
In a nutshell I'm trying to setup a PyODBC/Python script connection from Debian 10 (192.168.1.2) to Windows 10 in KVM/QEMU virtual system (192.168.1.12).
First, on the Windows 10/KVM, I see the ODBC Data Source Administrator has a tab File DSN and Microsoft Text Driver. Can I use FileDSN to test Python PyODBC connection to ODBC using a simple CSV file in place of Server?? (My research with ODBC only finds running server instances).
Next, what I tried:
On Debian I installed ODBC Microsoft driver for Linux.
Shutdown the Windows 10 firewall, and I can ping in both directions:
$nmap -p 22 192.168.1.12 # Deb to Win
> Test-NetConnection 192.168.1.2 -p 22 # Win to Deb
On Windows 10/KVM I added a FileDSN with Microsoft Text Driver. I created a CSV file (odbc_test_01.csv) with simple header and one row of data (IE. {'ID' : 1, 'NAME' : 'FOO'})
Created a Jupyter Notebook to make testing easier. Here is my connection string and the results:
cn = pyodbc.connect(r'Driver={ODBC Driver 17 for SQL Server};' # Driver installed above
r'FILEDSN=odbc_test_01.csv;' # my attempt at FileDSN
r'SERVER=192.168.1.12;' # KVM IP tested with ping
r'Trusted_Connection=no;' # explicit; use UID/PWD
r'UID=<username>;' # Windows user name
r'PWD=<password>', # Windows user password
autocommit=True)
OperationalError: ('HYT00', '[HYT00] [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired (0) (SQLDriverConnect)')
Tried isql from Debian command line with same string:
isql -v -k ''Driver={ODBC Driver 17 for SQL Server};FILEDSN=odbc_test_01.csv;SERVER=192.168.1.12; Trusted_Connection=no;UID=<username>;PWD=<password>'
Similar pages here at SO:
Authenticate from Linux to Windows SQL Server with pyodbc
Python pyodbc connect to Sql Server using SQL Server Authentication
An ODBC "File DSN" is not a driver for accessing data in a file. It is a way to specify a DSN (connection information for a target database) as values in a standalone file instead of in a standard configuration file on Linux (e.g., /etc/odbc.ini) or in the Windows registry.
If you need to "clone" a Windows DSN entry for use in a Linux environment then you may find my dump_dsn utility helpful. It retrieves an ODBC DSN from the Windows registry and presents it in a form that you could use to recreate the DSN on Linux.
For example, say I had a DSN named "mssql199" on Windows and when I ran dump_dsn.to_text("mssql199") on it I got
[mssql199]
Driver=ODBC Driver 17 for SQL Server
Description=with UseFMTONLY
Server=192.168.0.199
Database=myDb
Encrypt=No
TrustServerCertificate=No
ClientCertificate=
KeystoreAuthentication=
KeystorePrincipalId=
KeystoreSecret=
KeystoreLocation=
UseFMTONLY=Yes
Trusted_Connection=No
To use that same DSN on a Linux box I would have to
copy that block into /etc/odbc.ini (or equivalent, for a "System DSN") or ~/.odbc.ini (for a "User DSN") to use DSN=mssql199, or
save that block with an [ODBC] header instead of [mssql199] to a file, e.g., /home/gord/mssql199_file.dsn (for a "File DSN") and use FILEDSN=/home/gord/mssql199_file.dsn
Edit re: "Can I use FileDSN to test Python PyODBC connection to ODBC using a simple CSV file in place of Server??"
No. An ODBC DSN or FILEDSN on the Windows box will only be useful to connect from the Windows box to a data source (either locally, or on some other machine). We cannot connect from one machine (e.g., Linux) to an ODBC DSN entry on another machine
I created an SQLite database. Then I added SQLite drivers for ODBC.
I am trying to connect to a Pervasive Sql Server which is running on Windows machine from my Ruby application which is on Ubuntu Machine. Can Someone please help me on same. Thanks in advance
Below is my configuration on linux machine
/etc/freetds/freetds.conf
[pserver]
host = XXX.XXX.XX.XXX
port = 1583
tds version = 8.0
Under /etc/odbcinst.ini, I have saved the driver info like below
[freetds]
Description=freetds Driver
Driver=/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup=/usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
Trace=Yes
TraceFile=/tmp/freetds.log
ForceTrave=Yes
UsageCount=10
fileusage=1
dontdlclose=1
TDS_Version = 8.0
In /etc/odbc.ini, client and database details
[pclient]
Description = Pervasive SQL Server
Driver = freetds
Trace = Yes
Servername = pserver
Port = 1583
Database = "MyDatabasename"
TDS_Version = 8.0
tsql -S pserver -U db_username -P db_password -d MyDatabasename
above cmd gives error saying
Error 20009 (severity 9):
Unable to connect: Adaptive Server is unavailable or does not exist
OS error 111, "Connection refused"
There was a problem connecting to the server
iodbctest ["DSN=pclient;UID=db_username;PWD=db_password"]
this results in
iODBC Demonstration program
This program shows an interactive SQL processor
Driver Manager: 03.52.0812.0326
(iodbctest:6672): Gtk-WARNING **: 20:40:38.693: cannot open display:
Not able to understand the above result and how to handle this. Please help
As far as I know, the only way to access Pervasive PSQL from Ruby would be through ODBC. You need to use the Pervasive Client ODBC driver. Don't use the FreeTDS driver. I've never heard of using the FreeTDS driver to connect to Pervasive PSQL. In fact, this question mentions that FreeTDS doesn't work to Pervasive PSQL. Pervasive PSQL and Microsoft SQL Server are not the same product and the client for one cannot connect to the server of the other.
The short answer would be to install the Pervasive PSQL client on the Ubuntu machine, create the ODBC Datasource name pointing to the database on the Windows machine and then use ODBC from within Ruby to access the data.
You'll want to be on at least Pervasive PSQL v11.30, preferably Actian PSQL v13 (current version as of December 2018). You'll need to download and install the client appropriate for the application. If the Ruby application is 32 bit, you need the 32 bit ODBC driver. If the application is 64 bit, you'll need the 64 bit driver. The 'bitness' of the OS is not as important. You need to use the same PSQL client version as server version. You cannot use the v13 client with a v11 server.
This question already has answers here:
VBScript & Access MDB - 800A0E7A - "Provider cannot be found. It may not be properly installed"
(7 answers)
Closed 4 years ago.
I'm getting this error
Provider cannot be found. It may not be properly installed. Code:
800a0e7a Source: ADODB.Connection" when I try to run my VBScript
It's trying to connect to an Oracle database, here is the connection string:
Provider=OraOLEDB.Oracle;
Data Source=Data;
User Id=Username;
Password=password;
I have Oracle Client 32 installed, my machine is a 64 bit system. I've tried re-register Oracle OLEDB provider dll with:
C:\Windows\SysWOW64\regsvr32 \bin\OraOLEDB12.dll
I've tried opening it with a 32 bit driver and still keep getting that error. Any ideas?
By default your script will run in 64-bit mode. As your Oracle client is 32-bit you must run your script also 32-bit mode.
Try c:\Windows\SysWOW64\cscript.exe {your_script.vbs} to run it. Otherwise you would have to install the 64-bit version of Oracle Client.
I'm trying to connect to a remote oracle database in my perl app.
When running the app, the following error appears:
"Connection Error: ERROR OCINlsEnvironmentVariableGet(OCI_NLS_CHARSET_ID)"
I got Oracle Instant Client and placed it locally then set the Oracle Home env to it, as I don't have Oracle client installed there.
My code is below:
BEGIN {
$ENV{NLS_LANG} = "AMERICAN_AMERICA.UTF8";
$ENV{OCI_NLS_CHARSET_ID} = "AMERICAN_AMERICA.UTF8";
$ENV{ORACLE_HOME} = #The path to the instant Oracle client";
}
#Connect to database
my $DBHandle = DBI->connect(
"dbi:Oraclehost=$host;sid=$sid;port=$port",
$userName,
$passWord
) or die "Connection Error: $DBI::errstr\n";
I'm using ActiveStat perl on Windows Server 2008, ORACLE 10g
I could find the root cause. I used Oracle Instant Client lite (instantclient-basiclite-win64-10.2.0.5) which contains only binaries. Then I tried Oracle Instant Client - SDK, which contains only lib.
I found that I need to merge both to get my code working, I used the SDK as main client, created a bin directory into it then placed the lite client into it...it works !
Hi I am working on a project in which we have oracle DB that is hosted on one machine and java application on other machine. both machines have UNIX OS.i want to develop a shell script that will use DB query and generate a report but i dont have any client(SQLplus) installed on both the machine. so let me know how can i connect to DB and where shud i develop scirpt like on DB unix machine or application machine.
sqlplus -s "/as sysdba
this is use of sql plus i dont have on any machine..
if you have ssh access on both the machines you could run virtually any command(through ssh) you could on the machine itself:
ssh user#server1 "ls ~/"
for example the above will give you a listing of files in "user"s home directory on server1..