I am trying to connect to Sybase ASE from VB and getting following error
Function createConnection() As ADODB.Connection
Dim ConnectString As String Dim ConnString As String
Set conn = New ADODB.Connection
.Mode = adModeReadWrite
.ConnectionTimeout = 15
.ConnectionString = "Provider=ASEOLEDB;" & _
"Server Name=" & Range("DBServerName") & _
";Initial Catalog=db;" & _
"User Id=user;" & _
"Password=password"
.Open
End With
Set createConnection = conn
End Function
Any help would be much appreciated.
I would suggest you fist to check odbcad as described here.
If you can find any mention of ASEOLEDB there, then you just have problem either with the app using wrong type of drivers (32-bit vs 64-bit) or with a connection string.
But as the error message suggests, you might be missing just the provider - same problem as here. These libraries are usually part of these installations:
SAP/Sybase ASE
SAP/Sybase ASE PC Client CD
SAP/Sybase ASE SDK
All of these can be acquired on SAP portal, however you need a login to that place as this software is accessible only on purchase. You can find here a link of PC Client CD content (Sybase infocenter website) and a manual on OLEDB here.
Unfortunately only freely downloadable ASE is for Linux, which is useless for you. Maybe you can find on that W7 machine installation media ...
Download & Install Provider
http://devzone.advantagedatabase.com/dz/content.aspx?key=20&Release=19&Product=15
use below commands to register provider
regsvr32 sybdrvodb.dll
regsvr32 sybdrvodb64.dll
Details:
http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc20116.1550/html/aseodbc/aseodbc43.htm
Related
I have macro to run manually SQL Job Agent by using userid and Password
Sub Run_Job()
Dim con As Object
Set con = CreateObject("ADODB.Connection")
con.Open = "Provider=sqloledb; Data Source=SERVERNAME; Initial Catalog=DATABASENAME; User Id=USERNAME; Password=PASSWORD;"
con.Execute "exec msdb.dbo.sp_start_job ‘AGENTJOBNAME’"
Workbooks("WORKBOOKNAME.xlsx").Close
End Sub
But when my SQL Server must using Windows Authentication to login ,
how to create macro by using windows auth to run it?
Do small correction to your connection string
con.Open = "Provider=sqloledb; Data Source=SERVERNAME; Initial Catalog=DATABASENAME; Integrated Security=SSPI;"
It switches to integrated authentication.
I'm using an Azure WebApp (Tier: F1)
I hosted these files and directories:
/wwwroot/default.asp
/wwwroot/Data
/wwwroot/Data/customers.dbf
/wwwroot/Data/vessels.dbf
The default.asp file contains the following:
<%
On Error Resume Next
Response.Write("Path: " & Server.MapPath("Data") & "<br>")
DBRoot = "D:\home\site\wwwroot\Data\"
Set conn = Server.CreateObject("ADODB.Connection")
DataBase = "DRIVER={Microsoft Visual FoxPro Driver};SourceType=DBF;sourcedb="& DBRoot
conn.Open DataBase
If Err.Number <> 0 Then
Response.Write (Err.Description)
Response.End
End If
%>
And i'm getting this output:
Path: D:\home\site\wwwroot\Data
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
I'm not sure if the error is because:
The driver (Microsoft Visual FoxPro Driver) is not installed or supported in Azure
The path is incorrect (because web apps in Azure have a shared physical path)
How can I make this connection work?
Note: just as a reference, I intend to use these dbf files with SQL queries such as this:
<%
conn.Execute("SELECT * FROM [customers.dbf] WHERE userId ='"& userId &"'")
%>
All these used to work in an old hosting I had. It doesn't works in Azure.
Connecting to Cloud SQL appears to be different than connecting to normal MySQL databases.
I have added the 'Instance connection name' after the 'Public IP address'.
I am getting an error:
'Unknown MySQL server host'
Dim Cnn As Object
Set Cnn = CreateObject("ADODB.Connection")
Cnn.Open ("DRIVER={MySQL ODBC 5.3 Unicode Driver};SERVER=xxx.xxx.xxx.xxx\instanceConnectionName;DATABASE=databaseName" & ";USER=user;PASSWORD=abcd")
If Cnn.State = adStateOpen Then
Debug.Print "Connection"
Else
Debug.Print "No Connection"
End If
Cnn.Close
I would recommend to use the SQL Proxy and then for the connection would be like if the database was in your localhost.
So the steps would be:
Install Cloud SQL Proxy in your computer
Start the cloud SQL Proxy
Connect as I f you were connecting to a local database
the code would be:
Dim Cnn As Object
Set Cnn = CreateObject("ADODB.Connection")
Cnn.Open ("DRIVER={MySQL ODBC 5.3 Unicode Driver};SERVER=172.0.0.1;DATABASE=<DATABASENAME>;USER=<USERNAME>;PASSWORD=<PASSWORD>)
If Cnn.State = adStateOpen Then
Debug.Print "Connection"
Else
Debug.Print "No Connection"
End If
Cnn.Close
What kind of DB are you connection to? You can find all kinds of connection strings here.
https://www.connectionstrings.com/
Also, go to your ODBC drivers and see what you have installed. Your code has to match what you have installed. Here is an image of what I have on my system.
So, for instance, you have to have 'MySQL ODBC 5.3 Unicode Driver' installed because that's what you are referencing in your code. Try that and feed back with your findings and results.
I've installed on my Windows 10 machine an Oracle ODBC Instant Client 12 in order to connect my Excel macro to an Oracle database. My application is capable to connect to Oracle database by using DAO or ADO drivers. The connection to database works fine with DAO however when I try to use the ADO driver I'm getting the following error:
Provider cannot be found.It may not be properly installed
How I a ADO connection is being setup in Excel macro:
Set Connection = VBA.CreateObject("ADODB.Connection")
Connection.ConnectionString = IDatenbank_BuildConnectionString(ODBCConnection)
Call Connection.Open
IDatenbank_BuildConnectionString = "ODBC" & _
";DSN=" & ODBCConnection.Name & _
";Uid=" & ODBCConnection.User & _
";Pwd=" & ODBCConnection.Password
Any advice on how to work with ADO driver and avoid the error "Provider cannot be found. It may not be properly installed."
Excel 2016 is running on 32 bites on a Windows 10 machine used as a server. Microsoft ODBC is installed on 32 bits as the Excel instance.
What I have done until now:
Installed and Oracle Client for ODBC 32 bits;
Installed Access Database Engine for 32 bites;
Microsoft Data Access Components (MDAC)
In client machine they can run together however seems not be true when server is used.
You don't need the "ODBC" in front of your connection string if you are using standard Oracle ODBC.
From your code, it contains the "ODBC":
'ODBC;DSN=xxx;Uid=yyy;Pwd=zzz
IDatenbank_BuildConnectionString = "ODBC" & _
";DSN=" & ODBCConnection.Name & _
";Uid=" & ODBCConnection.User & _
";Pwd=" & ODBCConnection.Password
'It should be "DSN=xxx;Uid=yyy;Pwd=zzz" only without "ODBC" in front
IDatenbank_BuildConnectionString = "DSN=" & ODBCConnection.Name & _
";Uid=" & ODBCConnection.User & _
";Pwd=" & ODBCConnection.Password
I'm trying to connect to an Oracle Database from an Excel application and whithout a DNS. I found on a website that it's possible to use ADO, so this is why I tried to do. I'm new to this so I juste copied what I found on this website.
Here is my code so far :
Sub ADOtest()
Dim connection As New ADODB.connection
connection.ConnectionString = "UID = user1; PWD= my_pwd; DRIVER = {Microsoft ODBC for Oracle; Server= localhost; Database= orcl.my_domain;"
connection.Open
End sub
When I run this code, I get an error saying that the driver was not found.
The problem is that I have no idea of what I have to do with the driver (how to install it and configure it). Plus, I don't know which one I should use : I've read that there is a driver from Microsoft, another one from Oracle and also I've seen something about providers like msdaora.
The program will be used by many users, so I would like to choose the solution that is the lightest (not much to install on computers).
Thank you !
For COM based ADO (ADODB) you can use the OLE DB Providers.
One is from Oracle, called "Oracle Provider for OLE DB". You can download it from 32-bit Oracle Data Access Components (ODAC) and NuGet Downloads (assuming your Excel is 32-bit). The connection string would be
"Provider=OraOLEDB.Oracle;Data Source=orcl;User ID=myUsername;Password=myPassword"
The other one is from Microsoft. Please note, this provider is deprecated, you should not use it for new projects. Usually it should be available on your Windows. Be aware, like the provider from Oracle it also requires an Oracle Client to be installed on the PC! The connection string would be
"Provider=MSDAORA;Data Source=orcl;User ID=myUsername;Password=myPassword"
The data source is usually defined in tnsnames.ora file or at a LDAP server, for example:
orcl.my_domain =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(Host = localhost)(Port = 1521))
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
If you don't have such entry you can put everything into the connection string, e.g.
"Provider=OraOLEDB.Oracle;Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=localhost)(Port=1521))(CONNECT_DATA=(SERVICE_NAME=orcl)));User ID=myUsername;Password=myPassword"
Perhaps you have to enclose the data source value by double-quotes ("), I am not sure.
So, in any case you would have to install an Oracle Client at all PC's.
Where is your database server hosted? In your question you say Server=localhost;, this would be quite unlikely, i.e. it is in contradiction to The program will be used by many users. I doubt everybody has an Oracle Database server installed on his local host.