php 7 unable to initialize sqlsrv - dll

I searched all day to find out a solution for sqlsrv dll on php 7 VC14 x64 Thread Safe and i did not found a solution. Does anyone solved this issue :
[04-Oct-2015 19:48:05 UTC] PHP Warning: PHP Startup: pdo_sqlsrv: Unable to initialize module
Module compiled with module API=20131226
PHP compiled with module API=20141001
These options need to match
in Unknown on line 0
Here is my php7 RC4 informations :
System Windows NT 6.0 build 6002 (Windows Server 2008 Standard Edition Service Pack 2) AMD64
Build Date Sep 29 2015 17:15:28
Compiler MSVC14 (Visual C++ 2015)
Architecture x64

sqlsrv isn't ready for PHP7 yet but that's not true it wasn't released since 2012. Last release is from May 2015. Maintainer is Microsoft and version for PHP7 is planned on the beginning of next year.
https://github.com/Azure/msphpsql/issues/58
Update:
Driver is available for PHP up to 7.1 version even for Linux today (March 2017).
https://github.com/Microsoft/msphpsql

For future reference (tested on Windows 7 with Xampp and PHP 7.0.13):
Download and install ODBC drivers here: https://www.microsoft.com/en-US/download/details.aspx?id=36434
Download the DLL here (both 7.0. and 7.1.can be found): https://github.com/Microsoft/msphpsql/releases
Open your "php.ini" file and look for the "extension_dir" line. This will tell you where to put the DDL files. Note: On Xampp, it should be something like: "C:\xampp\php\ext"
Put the DLL files contains in the Zip archive in your extension directory. Make sure to select the proper select the proper version. Note: I initially tried to use the x64 version, but it didn't work. Then, I replaced the DLL with the x86 version and it finally worked.
Back in your "php.ini" file, you need to add the following line: "extension = php_pdo_sqlsrv_7_ts.dll". Note: Xampp use the tread safe version.
Make sure to restart your apache service.
Code sample for testing:
$db = "the name of your database"
$password = "password";
$server = "IP address or named pipe";
$user = "username"
try {
$connection = new PDO(
"sqlsrv:Server=" . $server .
";Database=" . $db,
$password,
$user
);
$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $exception) {
var_dump($exception);
}

For the record, the direct link to the sql server libraries is here
sqlsrvr for php 7
Is the 32 and 64 bits version both for ts and nts

Related

How to build/compile/load in the QOCI driver in Qt on RHEL 7 Linux?

I am developing a RHEL 7 Qt application and need to connect to an Oracle database. When calling QSqlDatabase::addDatabase("QOCI"), I am prompted with the following:
QSqlDatabase: QOCI driver not loaded
QSqlDatabase: available drivers: QSQLITE
I have Oracle Install Client v11.2 installed, but I'm not sure where to go from here. I've done extensive research and cannot find a solution.
Based on what I saw online, I tried creating an oci directory within my Qt dir (/usr/lib64/qt5/plugins/sqldrivers) and then created an oci.pro file. Its contents are below:
INCLUDEPATH+=/usr/include/oracle/11.2/client
LIBS+=-L/usr/lib/oracle/11.2/client/lib -lclntsh
TEMPLATE = subdirs
I ran qmake-qt5 on this to generate a Makefile, but when I run make, the necessary QOCI .so file is not generated.

Asp.net 5 DNX and DNU not working in Windows Server 2008 R2

I have successfully installed the dnvm using commands given here https://github.com/aspnet/home.
Now I am trying dnvm upgrade but somehow it is not working for me. I get the latest version from nuget and I can see it being created to my .dnx\runtimes folder. See following:
C:\Users\Administrator>dnvm upgrade
Determining latest version
Downloading dnx-clr-win-x86.1.0.0-beta4 from https://www.nuget.org/api/v2
Installing to C:\Users\Administrator\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta4
Adding C:\Users\Administrator\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta4\bin to process PATH
Adding C:\Users\Administrator\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta4\bin to user PATH
Updating alias 'default' to 'dnx-clr-win-x86.1.0.0-beta4'
C:\Users\Administrator>dnu
C:\Users\Administrator>
C:\Users\Administrator>dnx
C:\Users\Administrator>
C:\Users\Administrator>dnvm list
Active Version Runtime Architecture Location Alias
------ ------- ------- ------------ -------- -----
* 1.0.0-beta4 clr x86 C:\Users\Administrator\.dnx\runtimes default
dnvm upgrade works ok? but nothing happens when I type dnu, dnx,dnu restore commands. What am I missing ?I am doing it in Windows Server 2008 R2. .Net framework 4.5.2 installed.
Update
I just tried to get latest unstable runtime. When using beta6-12085 the dnu command returns an error: dnx.win32.dll could not be loaded. Last error: 87
C:\Users\Administrator>dnvm upgrade -u
Determining latest version
Downloading dnx-clr-win-x86.1.0.0-beta6-12085 from https://www.myget.org/F/aspnetvnext/api/v2
Installing to C:\Users\Administrator\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta6-12085
Adding C:\Users\Administrator\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta6-12085\bin to process PATH
Adding C:\Users\Administrator\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta6-12085\bin to user PATH
Updating alias 'default' to 'dnx-clr-win-x86.1.0.0-beta6-12085'
C:\Users\Administrator>dnu
dnx.win32.dll could not be loaded. Last error: 87
I had a new install of Windows Server 2008. Installing all the updates fixed the problem!
It seems, dnx compiled on windows 8 hence corresponding "minwin" version binding.
https://blogs.mcafee.com/mcafee-labs/windows-7-kernel-api-refactoring . I got "error 87" on win7 too.

Apache/Perl Cannot Find MDAC without CommonProgramFiles(x86)

I am having a problem with using Apache/Perl to get access to Excel files using Microsoft Data Access Component (MDAC). Somehow I must set the "CommonProgramFiles(x86)" system environment variable in order to get this to work. Otherwise, I keep getting this error message:
System.InvalidOperationException: The .Net Framework Data Providers
require Microsoft Data Access Components(MDAC). Please install
Microsoft Data Access Components(MDAC) version 2.6 or later. --->
System.IO.FileNotFoundException: Retrieving the COM class factory for
component with CLSID {2206CDB2-19C1-11D1-89E0-00C04FD7A829} failed due
to the following error: 8007007e.
The server configuration is:
Windows Server 2008 R2 in 64-bit
Server is installed with Microsoft Access Database Engine 2010
Apache 2.2.25 (that is 32-bit)
Perl 5.12.3 v5 (that is also in 32-bit)
I have my Perl CGI script to call my C# program (that is built for "Any CPU").
The C# program uses MDAC to open and read Excel files (not trying to launch Excel, only try to read data from the Excel files).
I have verified that the server has the latest MDAC available in these 2 folders:
C:\Program Files\Common Files\System\Ole DB
C:\Program Files (x86)\Common Files\System\Ole DB
I have also checked the registries and they look fine. Anyway, I don't have any problem running my C# program directly at the command prompt (it can use MDAC to get access to Excel files). I only have the problem when I use Apache/Perl to use my Perl CGI script to call my C# program (that is when I get that error with MDAC).
I can work around this problem by specifying CommonProgramFiles(x86) in my Perl CGI script, like this:
$ENV{ "CommonProgramFiles(x86)" } = "C:\\Program Files (x86)\\Common Files";
I have this question:
Why do I have this problem? And why setting that CommonProgramFiles(x86) system environment variable can workaround this problem? Why that system environment variable is empty before I set it? Does this have to do with the fact that I am running 32-bit Apache/Perl in a Windows operating system that is 64-bit?
Please help me to understand this issue. Thanks in advance.
(The original version of this post had a question about a second problem. Turned out that problem had to do with an extra double quote in the string. I fixed this, and that problem has gone away. That's why I have removed that second question from the post)
Jay Chan
I did some more research and the issue is the following: until release 2.4.9, the Apache startup routines have mapped "commonprogramfiles(x86)" to "commonprogramfiles_x86_" and that variable does not exists in the environment unless you create it... I have not tested it, but creating that environment variable and making it point to the same location as commonprogramfiles(x86) would probably fix the issue too.
Since the compiled Apache distributions are only using up to version 2.4.46 as we speak, they don't have the fix that allows the parenthesis in environment variables. That's why you still need the PassEnv directive to ensure that Apache passes the correct values to 32-bit CGI scripts.
The following post has some useful details about this:
https://bz.apache.org/bugzilla/show_bug.cgi?id=46751
I used to have the same problem in with Apache 2.4 with dBase compiled apps using ADO-32 bit as dBase is 32-bit. Something has recently changed, possibly with Windows 10 2004 20H2. I needed this fix in July-Aug 2020 but now I don't, the environment variable already exists. Since my Apache version is dated April 2020, that cannot be the reason for the change.
I tried to do some research about this but all I could find is that those environment variables are system ones existing at least since 2017, so why I needed to set this var is a mystery to me, but I would like to understand this, so if you find something, post a follow-up...
https://learn.microsoft.com/en-us/windows/deployment/usmt/usmt-recognized-environment-variables

How do I resolve the error ORA-06413: Connection not open?

My local environment VS2012
Using Oracle 10g XE
Dim dbConn As New OleDbConnection
Dim dbComm As OleDbCommand
dbConn.ConnectionString = "Provider=msdaora;Data Source=XE;User ID=scott;Password=tiger"
dbConn.Open()
Tip error: ORA-06413: Connection not open.
Already check the TNSNAMES.ora, SQLNET.ora, LISTENER.ora and its nothing wrong.
But why this error appear?
:(
The error is caused by the parenthesis in the pathname.
possibly you execute VS2012 from C:\program file (x86)...
workaround: create a junction link
steps:
from: command line execute
C:>mkLink /j "Program Files x86" "Program Files (x86)"
and then
fix the (or create a new) shortcut with new path (C:\program file
x86...)
I worked a lot on this problem, I lost a lot of time. Apparently IIS Express in Visual Studio uses the Oracle provider 64 bit.
To solve this problem:
I installed IIS on my PC (Windows 10)
with .NET 4.5 or higher
I compiled the Web API application with 32-bit target.
I publish the web application on my IIS.
On IIS I set enable the apps 32 bit to true
I had the same problem and I resolved the problem installing Oracle 11g Express. Before, I removed all previous Oracle client installation. I use windows 7 64 bit.
Create Bat file to start excel
in bat put path you can adjust to match your folders
start c:\progra~2\micros~1\Office14\Excel.exe
When you start excel just open macro and try :)
I encountered the same problem when working on my Visual studio 2013 project. I was able to run the same project from SVN on a different machine, but it just WON'T work on mine. I checked the connection string and could successfully test the connection in Oracle, but it would throw a disgusting “ORA-06413: Connection not open” error from code.
I got it fixed this way - Install Oracle 11g client -> Select "Administrator" as Type of Installation. Re-open Visual Studio and it worked. Hope it helps!
uninstall your toad or oracle
reinstall on on your window drive ex:(c/d/e) in new folder
don't install in program files (x86)
because program files(x86) is for 32 bit applications
I have resolved the error after the days of searching.
Error Cause:
This error is due to Oracle reserved character "(",")" and in Windows 64 bit there is a folder "Program Files (x86)" which is a creation problem.
Solution:
Create a link folder for "Program Files (x86)" using below command on Window Drive path.
Open cmd as Administrator.
mklink /j "Program Files x86" "Program Files (x86)"
or visit link
download3k article
Open Registry (as Administrator)->Export Registry
Always backup a registry file before changing it. Make a copy of the registry file and work on the copy.
Open Registry file(Copy) in text editor and replace "(x86)" with "x86"
Save the file and import it to your Registry and restart your computer.
Now the "ORA-06413: Connection not open" error goes away.

Installing Orafce.sql 3.0 in Windows 7

As mention in Orafce Install.orafunc:
..install Orafce functions in the database, either run the orafce.sql script using the pgAdmin SQL tool..
I tried running the orafce--3.0.sql in pgAdmin sql editor. This give me error
ERROR: could not access file "MODULE_PATHNAME": No such file or directory.
What do you mean by module path?
Installed program:
strawberry perl with DBD::Oracle
postgresql 9.3
pgAdmin III
Not fully installed:
ora2pg
I tried installing ora2pg...with a problem.
H:\PostgreSQL\ora2pg-12.1>perl makefile.pl
Unparsable version '' for prerequisite DBD::Oracle at makefile.pl line 553
Generating a dmake-style Makefile
Writing Makefile for Ora2Pg
Writing MYMETA.yml and MYMETA.json
Done...
H:\PostgreSQL\ora2pg-12.1>dmake && dmake install
"Installing default configuration file (ora2pg_dist.conf) to C:\ora2pg"
Appending installation info to C:\strawberry\perl\lib/perllocal.pod
dmake: Warning: -- Target [install] was made but the time stamp has not been up
dated.
Suggested Solution:
I downloaded a copy of orafce from okbob github
Unzip the file to folder D:/Postgresql/orafce-master
I copy only the following files
orafce--unpackaged--3.0.6.sql
orafce--3.0.6.sql
orafce.control
to folder C:\Program Files\PostgreSQL\9.3\share\extension
Then I try running this command in pgAdmin III sql tools.
CREATE EXTENSION orafce;
I received this Warning and Error.
[WARNING ] CREATE EXTENSION orafce
ERROR: syntax error in file "C:/Program Files/PostgreSQL/9.3/share/extension/orafce.control" line 1, near end of line
I checked orafce.control content. It has this config.
# intarray extension
comment = 'Functions and operators that emulate a subset of functions and packages from the Oracle RDBMS'
default_version = '3.0.6'
module_pathname = '$libdir/orafunc'
relocatable = false`
I can't pass to this wall. What seems the problem?
So, you are working with source raw files. You should to compile these files first - and later you can use it. It is relative simply on Unix like platforms, where C compiler is usually available, and pretty hard on MS Windows, where you have to install C compiler first.
I afraid so we lost pgFoundry archive, where was orafce precompiled and packed.
Almost all Linux distributions support orafce directly - and you can install it without compilation from repositories.
see http://wiki.postgresql.org/wiki/Building_and_Installing_PostgreSQL_Extension_Modules
$libdir is symbol, that is used for PostgreSQL extensions directory. It can be different for any platform - and it is replaced inside compilation stage by actual value. MODULE_PATHNAME has similar meaning. In compilation stage is replaced by valid actual path to library with compiled code.
I am sorry - we don't provide a compiled files - mainly due high risk for MS Windows. We have no forces, and tools to maintain all Win safely. In this moment, you can:
try to contact someone who use orafce for windows for backup of orafce installers
try to compile this extension by self (Microsoft Visual Studio Express edition is free and downloadable on internet).
other possibility is migrate database server to Linux - almost all database maintenance and usage is more simply and more robust there (due missing viruses, antiviruses and less resource requests). The Linux is primary platform for Oracle too.
some tutorials:
http://blog.2ndquadrant.com/compiling-postgresql-extensions-visual-studio-windows/
http://www.scribd.com/doc/40725510/Build-PostgreSQL-C-Functions-on-Windows