VBScript & Access MDB - 800A0E7A - "Provider cannot be found. It may not be properly installed" - ms-access

I've having a problem with a VBScript connecting to an access MDB Database. My platform is Vista64, but the majority of resources out there are for ASP/IIS7.
Quite simply, I can't get it to connect. I'm getting the following error:
800A0E7A - "Provider cannot be found. It may not be properly installed"
My code is:
Set conn = CreateObject("ADODB.Connection")
strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\database.MDB"
conn.Open strConnect
So far I have ran %WINDIR%\System32\odbcad32.exe to try to configure the Driver in 32bit mode, but it hasn't done the trick. Any suggestions would be greatly appreciated
Just as an addition, I'm trying to get this .vbs script to run by double clicking and letting it do it's thing. This code isn't embedded into another lang/script.

run script with SysWOW64 version
C:\Windows\SysWOW64\wscript.exe or cscript
instead of the default 64bit version from C:\Windows\System32

On Microsoft TechNet Configuring IIS to Run 32-bit Applications on 64-bit Windows (IIS 6.0):
To enable IIS to run 32-bit applications on 64-bit Windows:
Open a command prompt and navigate to the %systemdrive%\Inetpub\AdminScripts directory.
Type the following command:
cscript.exe adsutil.vbs set W3SVC/AppPools/Enable32BitAppOnWin64 "true"
Press ENTER.
Alternatively, via Internet Information Services (IIS) Manager:
Access Application Pools
Right click on "ASP.NET v4.0 Classic"
Select "Set Application Pool Defaults ..."
Under General change "Enable 32-Bit Applications" from "False" to "True"
Click OK
If you wish to run both 32-bit and 64-bit applications, there's various blogs to do it, such as Rakki Muthukumar's blog IIS7 - Running 32-bit and 64-bit ASP.NET versions at the same time on different worker processes.

Alternatively, via Internet Information Services (IIS) Manager:
Access Application Pools
Right click on "ASP.NET v4.0 Classic"
Select "Set Application Pool Defaults ..."
Under General change "Enable 32-Bit Applications" from "False" to "True"
Click OK
When I change this settings it is worked. thank you guys.. :)

Just use
strConnect = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source= "
if you 've all needed drivers

I used this it worked for me without any error:
sconnect = "Provider=MSDASQL.1;DSN=Excel Files;DBQ=" & myPath & ";HDR=Yes';"
Set con = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
con.Open sconnect
sSQLQry = "SELECT * FROM [" & tableName & "];"
Set rs = con.Execute(sSQLQry)

we had same issue where we were getting exception
Provider cannot be found. It may not be properly installed
with following machine configuration:-
machine:- window 10
oracle client installed:- oracle 12c
provider:- MSDAORA.Oracle (instead of OraOledb)
we have read number of blogs to resolve this where every post saying configuration issue between oracle client 12 to 11G version having 62 to 32bit inter dependency and lot more but it got resolved while changing the provider name from capital letter to small.
earlier provider name was:- MSDAORA.Oracle (Here Oracle "O" is in capital letter )
now provider name is:- MSDAORA.oracle (Here oracle "O" is in small letter )
please give a try, if that works for you :)

Check this out
EDIT: Warning, the link below goes straight to a download of 2007 Office System Driver: Data Connectivity Components.
http://www.microsoft.com/download/en/confirmation.aspx?id=23734
Installed it, read the instruction and everything worked as a charm.

Related

Connect to online mySQL database using VBA

Objective:
I'm trying to connect to a database (e.g. associated with a website hosted by goDaddy) via VBA; using MS Word. I would like to distribute the VBA code via a word template so that others can also connect to my database.
Current Understanding - Is it correct?
In order to connect to a remote mySQL database I MUST configure a ODBC Data Source using (for example) mySQL Connector/ODBC (available here)?
There seems to be a way to connect without using a DSN as suggested here.
Issue:
I have been trying to use the mySQL Connector tool and am attempting to configure it with the information I have at hand. Steps taken:
download connector tool from dev.mysql.com
Control Panel > System & Security > Administrative Tools > ODBC Data Sources 64 Bit
add host: www.mywebsite.com
add user: NameOfDataBaseUser
add pwrd: PWForUser
I get the impression that I am using the wrong credentials... I found some documentation that said a list of DataBases would be displayed if connection is successful. That suggests to me that I should be using credentials for a master user - which user would that be?
Disclaimer
I do plan to connect to an online DB via VBA, but suspect that it might be better to connect indirectly via a php web-page.
If anyone has thoughts on this (security, ease of deployment, other) please let me know, it would probably be a new question. Other disclaimer, I am highly INexperienced with databases but keen to learn - slowly ;-)
I am currently working on a project with Excel where I am successfully connecting to a remote MySQL database.
I am using the DSN-less approach and this could probably work well for you, too:
Set remoteCon = New ADODB.Connection
conStr = "DRIVER={MySQL ODBC 5.3 Unicode Driver};" & _
"SERVER=myhomepage.com;PORT=3306;DATABASE=mydb;" & _
"UID=username;PWD=secret"
remoteCon.Open conStr
remoteCon.Execute ("USE mydb;")
In order for this to work, you also have to add a reference (in VBA backend): Tools > References > Check "Microsoft ActiveX Data Objects x.x Library".
You also need to have the MySQL ODBC Driver (in my case "MySQL ODBC 5.3 Unicode Driver") installed on your computer.
Queries can then be executed like this:
Dim rs As ADODB.Recordset
Set rs = remoteCon.Execute("SELECT * FROM table")
If Not rs.BOF And Not rs.EOF Then
result = rs.GetRows
End If
How to connect VBA to a Remote mySQL DataBase using ODBC
Thanks to #EVilliger & #tobifasc for your help with this, there are many 'how to configure mySQL questions' floating around but none that solved my (larger) issue.
Basic problem - my host does NOT allow remote connections to the database, except for from a single white-listed IP (this seems fairly common).
Questions Answered:
It turns out that you do NOT need to configure the mySQL connection using the connector, however you DO NEED to have an appropriate ODBC driver installed. The connector (with the driver) can be found here: https://dev.mysql.com/downloads/connector/odbc/
I uninstalled the mySQL Connector and everything seemed to continue working, until it didn't. Conclusion don't uninstall the mySQL Connector unless you have something to replace it with.
The credentials to use can be for a database user, not some elevated user.
For anyone interested in setting up and experimenting with mySQL from VBA here is a way forward:
Download & install the drivers (see above) - if the install fails you may need to install vcredist_x64.exe
Set-up a free mySQL database, I used HelioHost: https://www.heliohost.org/ (they will also give you a domain)
Create a database & user in HelioHost cPanel
Configure remote access - use wildcard % to allow all IPs
Add user to database
Use the following code to connect...
Code from accepted answer:
Sub connect2OnlineSQL()
' Note: add referecne to Microsoft ActiveX Data Objects #.# Library
' Tools > References > (scroll down...)
Set remoteCon = New ADODB.Connection
conStr = "DRIVER={MySQL ODBC 5.3 Unicode Driver};" & _
"SERVER=something.heliohost.org;PORT=3306;DATABASE=db_name;" & _
"UID=db_user;PWD=yourPassWordHere"
remoteCon.Open conStr
remoteCon.Execute ("USE db_name;")
End Sub
Thanks again :)
Following solution worked for me
Prerequisite:
Under Developer ->Tools->Reference Add the relevant Plug in for Oracle
Download and install ODBC Driver version for Oracle which you are using (32bit/64 bit)
Windows search -> ODBC Data Source -> Add Oracle driver under user DSN and System DSN
Copy paste below code which I used for MySQL and change the parameter based on your requirement
Sub ConnectToDB()
dbName = InputBox("Enter DB Name")
'Connection To MySQL
Dim oConn As ADODB.Connection
Dim str As String
str = "DRIVER={MySQL ODBC 8.0 Unicode Driver};SERVER=localhost;DATABASE=Employeeportal;PORT=3306;UID=root;PWD=root;"
Set oConn = New ADODB.Connection
oConn.Open str
MsgBox "Connected to MySQL DB"
'Exporting result set to Excel
Dim query As String
query = "select * from " & dbName
Dim recordSet As New ADODB.recordSet
recordSet.Open query, oConn
Sheet1.Range("A1:D1").CopyFromRecordset recordSet
oConn.Close
End Sub

LotusScript - How to connect to MySQL?

Sorry for possible dublicate.
I am trying to connect to my MySQL database from my LotusScript code (in some of my legacy projects):
Option Public
Option Declare
UseLSX "*LSXODBC"
Sub Initialize
Dim mysqlConnection As New ODBCConnection
Dim sqlQuery As New ODBCQuery
Dim result As New ODBCResultSet
Call mysqlConnection.ConnectTo("url","root","111111")
If Not mysqlConnection.IsConnected Then
MessageBox "No connection. Try again later."
Exit Sub
Else
MessageBox "Connection success."
End If
End Sub
I can't figure out what is the correct way to set the url of my database in LotusScript. I have already tried many variants of possible solutions, but nothing worked, also found many different urls, but also not helped.
Situation:
For example, I am trying to connect to my localhost MySQL base in port 3306 with name "test_db".
Question:
How must the url looks like for this?
p.s. also, if you have more possible ways to connect to MySQL DB from LotusScript - I will be very glad to see them.
Thanks.
As per the documentation for the ConnectTo method of ODBCConnetion class, you don't specify a URL. You specify a Data Source Name, otherwise known as a DSN. This is a name that you assign when you configure a connection in the 'Data Sources (ODBC)' tool on the Windows machine where the code will be executing.
On Windows 10, the 'Data Sources (ODBC)' tool is found in the Control Panel listed under Administrative Tools. On a Windows 2008 server that I happen to have handy, Administrative Tools is directly on the Start Menu. I'm sure they've hidden it in other places on other Windows versions. (I have a dim memory of it being under 'Accessories' on some versions.)
Note that on 64 bit versions of Windows, you need to be cognizant of whether your code is running in a 32 bit environment - as it is if it runs in the Notes client, or in a 64 bit environment, which it might be if it is running in background on a Domino server. There are separate 32 and 64 bit versions of the 'Data Sources (ODBC)' tool, and it does matter which one you use. If you're at all unsure, run them both and configure the same DSN name in each of them,

Excel VBA connect to MySQL - architecture mismatch error

I am trying to connect to MySQL from my local machine located on a server using VBA. Initially I was receiving the below error.
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified.
After some research, I figured out that the MySQL ODBC driver should be installed first. I installed the driver from the below location.
http://dev.mysql.com/downloads/connector/odbc/
I have a 64 bit machine and so I installed the driver for 64 bit and tried to establish the connection. Even then I was receiving the same data source name not found error. However from the ODBC data source administrator, if I select System DSN, I am able to see MySQL driver installed and I am able to create a new data source for my database in the server.
However from VBA, if I call the data source I receive another error.
[Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application.
This is how I am calling the data source from my VBA.
Dim oConn As ADODB.Connection
Set oConn = New ADODB.Connection
oConn.Open "data_source_name"
Also,for the 64 bit ODBC connector I am able to see two drivers as below in my System DSN.
MySQL ODBC 5.2 ANSI Driver
MySQL ODBC 5.2 Unicode Driver
For both of the drivers, my connection is successful from the ODBC data administrator.
I tried to figure out a solution for the architecture mismatch problem and I read if I create the DSN by running the ODBC application from the below location on a 64 bit machine, it might work.
C:\Windows\System32\odbcad32
However for this scenario too, I received the same architecture mismatch error.
I even tried installing MySQL Connector/ODBC 5.2.5 32 bit in my machine. For this case, I am not able to see the driver listed in the system DSN.
Can someone help me figure out what am actually doing wrong?
I can select and loop thru results sets and do inserts. data verified in db. let me know if you need help
windows 7 Ultimate
version 6.1 (build 7601: service pack 1)
64 bit
************************************************************************
ODBC Data Source Administrator
run by command: %windir%\system32\odbcad32.exe
2 drivers:
MySQL ODBC 5.2 ANSI Driver , 5.02.05.00, Oracle, MYODBC5A.DLL, 4/4/2013
MySQL ODBC 5.2 Unicode Driver , 5.02.05.00, Oracle, MYODBC5W.DLL, 4/4/2013
************************************************************************
create System DSN, named hp
using Unicode Driver
dsn=hp
descr=hp
tcpip server=192.168.1.11
user=root
password=xxxxx
Database=test
************************************************************************
ODBC Data Source Admin tool
far right tab called About
Admin, Control Panel, Cursor Library, Driver Mgr, Localized R DLL, Unicode Cursor Lib all Version 6.1.7601-ish
************************************************************************
MSFT Office Professional Plus 2010
Version 14.0.6129.5000 (64 bit)
VBA 7.0
Tools Menu / References / References - VBAProject, scroll down, click on:
Microsoft ActiveX Data Objects 6.1 Library
References Location= c:\program files\common files\system\ado\msado15.dll
************************************************************************
code same, get into an excel Macro:
Sub Macro1()
'
' Macro1 Macro
'
Dim oConn As ADODB.Connection
Dim rsPass As ADODB.Recordset
Dim sql As String
Set oConn = New ADODB.Connection
oConn.Open "hp"
Set rsPass = New ADODB.Recordset
sql = "select * from charlie1"
rsPass.Open sql, oConn
rsPass.Close
sql = "insert into charlie1 (billybob,birthdate,funny_num) values (5,now(),383.111)"
rsPass.Open sql, oConn
End Sub
Run Task Manager and look for EXCEL.EXE - most likely it has *32 after it (the issue is you are running a 32-bit version of excel, attempting to use the 64-bit version of MySQL Connector/ODBC).
To resolve:
Be sure to remove any defined ODBC data sources (DSNs) before
uninstalling the 64-bit driver (unable to remove if the driver is
already uninstalled)
Uninstall 64-bit MySQL Connector/ODBC driver
Download and install 32-bit version of MySQL Connector/ODBC driver
To setup DSN, see this http://forums.mysql.com/read.php?37,357786,360776#msg-360776
Note: You may be able to have both the 64-bit and 32-bit drivers installed and therefore not require uninstall of the 64-bit version. I did not need both so I haven't tested whether it is possible to have both installed.
I was recently fighting with this problem myself.
Taking advice from iOSdedude, I followed the link you originally posted, downloaded the 32-bit driver, and my ODBC connection started working again.
I am running Windows 7 on and my OS shows 64-bit under My Computer --> Properties --> System Info, so I was surprised to see that the 64-bit driver didn't work.
Not a good explanation as to why this works, but it worked for me.

Classic ASP - Ado Recordset Open()

I am trying to set up a legacy site written in ASP Classic on my local machine. I am using SQL Server 2008 and IIS ver 7.5.
I am running into an error when I try to open a connection to the database.
I used the advice in this post
to use a .udl file to create and test my connection string so I know the connection string works. I am using Windows Authentication and I am certain the app pool that is running this site has access to the database as I use the same pool for multiple sites and they can all connect fine.
When opening the connection I am trying to run a stored procedure, if I just write out the stored proc string and run it directly in my database it works as expected.
Here is the code:
Const adUseClient = 3
Const adCmdStoredProc = 4
Const adOpenStatic = 3
Const adLockBatchOptimistic = 4
dim connectstring,sql
connectstring = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=my-database;Data Source=(local)\SQLEXPRESS"
sql = "MyProc '" & param1 & "','" & param2 & "'"
set rs = Server.CreateObject("ADODB.RecordSet")
rs.CursorLocation = adUseClient
rs.CursorType = adOpenStatic
rs.LockType = adLockBatchOptimistic
' this is where it is failing
rs.Open sql, connectstring, 3
One of the problems is the error I get seems to be generated by IIS, it simply says:
An error occurred on the server when processing the URL. Please contact the system administrator.
If you are the system administrator please click here to find out more about this error.
When I click on the "click here" link it takes me to a general page about running ASP Classic sites on IIS 7, I couldn't find anything that seemed relevant to my error though. I can't seem to find where to get information about the error. As a last resort I checked in Event Viewer->Windows applications logs but there was no entry for my errors.
I've Googled and tried multiple permutations on the connection string but to no avail. If anyone had any advice on how to solve this problem, or even an idea of where to look for a solution I would be grateful. Thanks much!
**EDIT: **
Ok I changed IIS settings to show errors in the browser and now I am getting an error message that is a bit more useful, here it is:
Microsoft OLE DB Provider for SQL Server error '80004005'
Cannot open database "rw-gp" requested by the login. The login failed.
Now when I Googled this I found that this can often be a permissions issue. As you can see I am using Windows authentication and I am running the site under an app pool that has permission to connect to the database. I have multiple ASP.NET sites set up locally that run in this app pool and they can connect using integrated security. I'm not sure what is going wrong, does anyone have any suggestions?
An ASP Classic script always runs using impersonation (this is different from ASP.NET where impersonation is off by default).
Hence the user that needs access to the DB by virtue of your use of SSPI needs to be the user being impersonated.
The impersonated user is by default the the IUSR account specified as the anonymous user however if you have turned on windows integrated security then user may well by the user account the the client browser is running under. In either case you need to make sure that the user being impersonated has access to the DB or stop using SSPI.
If you are only using anonymous access you can specify via IIS manager that the account to use for anonymous access is the app pools identity.

classic asp connecting to access database, file not found

I am having to work in classic ASP for a small job.
I am trying to get the site running on my computer to test. I am running Windows 7 and IIS 7.
I get an error when running from local host and on checking the logs I get the error:
80004005 | Could_not_find_file_'c:\inetpub\wwwroot\sc\website\data\si.mdb'
My code is like so
dim objConn
dim objRS
set objConn = Server.CreateObject("ADODB.Connection")
objConn.Provider="Microsoft.Jet.OLEDB.4.0"
Set objRS = Server.CreateObject("ADODB.Recordset")
objConn.Open("c:/inetpub/wwwroot/sc/website/data/si.mdb")
This is the exact path to the file however.
Anyone know how I can access this? Is the code wrong or are there IIS settings I need to set?
I do not have any version of Office installed, would that cause a problem?
I have tried lots of different paths and provider settings but none have worked.
Edit
The code I am working on actually didn't have any connection string details in the code but the person said it still worked on thier computer as a friend setup the test environment.
He doesn't recall how his friend setup but said " What I remember from watching him, he connected to the database through Data Sources (ODBC) because as you said in the code theres no direct path as its using a 'global something' (dont know the right term)."
You could try using Process Monitor to see exactly which file is not being found or it is being caused by a permissions issue.
Also, although using forward slashes instead of backslashes isn't usually a problem, you may want to try changing that in case it makes any difference.
If you're using an x64 version of windows, JET is not supported in this mode, though you can get around it by configuring IIS to run x32 applications. To do this, run the following at the command line:
cscript.exe adsutil.vbs set W3SVC/AppPools/Enable32BitAppOnWin64 "true"
iisreset
The second command may not be required, but I'm guessing that you would probably need to restart IIS before this change takes effect.
It sounds like the code was previously set to use a global DSN, hence the lack of a path in the connection string, though there should have still been some kind of connection details (like the DSN name).
This may be a permissions issue.
An easy way to check would be to give full access to everyone for the directory the file is in.
Maybe you could use the Server.MapPath function as used here http://www.aspwebpro.com/tutorials/asp/dbconnectionopen.asp
Your connection string doesn't look right to me.
See if this helps.
EDIT: Do you have JET oledb provider installed?
EDIT2: Check for existence of oledb provider with help from this question.
How to check if an OLEDB driver is installed on the system?
I answered a potentially related question the other day. Are you running 64-bit windows 7? If so there is absolutely NO Jet support for x64 OSes. In a real .NET application you could simply recompile the application with x86 as the target. But in your case I am not sure of the solution.
Seth
Why does your string say:
"c:/inetpub/wwwroot/sc/website/data/si.mdb"
instead of the normal windows path
"c:\inetpub\wwwroot\sc\website\data\si.mdb"
Also, you could go to Control Panel->Administrative Tools->Data Source (ODBC) and create a new named DSN under the System tab. Name it si for example and make sure the type is access, give it the right path to the access db and then your code would just be:
dim objConn
set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open("si")