Connect to a PostgreSQL database through ODBC on Excel 2016 - sql

I'm having trouble using ODBC to connect from Excel 2016 to a PostgreSQL database.
I tried to follow this answer, without success, and this solution from MS, without any better results...
Has anyone ever succeeded at this? I saw that Excel 2016 had some troubles with ODBC drivers, but that was like a year ago, so I was wondering if things may be better now?
Thank you for your help.

My guess is this is a 32/64 bit thing. It's the single biggest issue we've had with setting people up on PostgreSQL within Excel/Access.
Bottom line: if your Excel instance is 32-bit (which is often the case), then you need to use the 32-bit ODBC driver. The latest Pg ODBC driver has both bundled in the same assembly, so the trick is to go into 32-bit ODBC and set up the driver that way.
From there, it should all be straight-forward:
Data Tab
From Other Data Sources
Microsoft Query
Select the Data source you just set up
And so on.

II am working on a Windows 10, 64-bit version, but turns out my Office package is 32-bit. Once I manually installed the 32-bit postgresql driver here: https://www.postgresql.org/ftp/odbc/versions/msi/, i was then able to correctly enter the Driver along the lines of these guidelines: https://www.connectionstrings.com/postgresql/
Final connection string looked like:
Driver={PostgreSQL ANSI};Server=name.text.ap-southeast-2.rds.amazonaws.com;Port=5432;Database=myDBname;

I had this as a comment before, but another commentor suggested I make this an answer: on excel 2016 for windows, don't waste your time with Data>Get Data >From Database. Instead use Data>Get Data >From Other Sources> From ODBC. To set up the ODBC: Click on the Start Menu. Select Control Panel. Select Administrative Tools and double click the Data Sources (ODBC) icon. Click on the System DSN tab. Here is a more detailed article that I pulled the ODBC set-up text from. Besides being much easier to set up, "From ODBC" comes with Office Business, or Office Home, while "From Database" only comes with Office Pro.

1.Excel 2016, x86
2.You need x86 odbc-driver
https://www.postgresql.org/ftp/odbc/versions/msi/
I used psqlodbc_13_02_0000-x86.zip
3.Create DataSource
-Control Panel
-Administration
-Open the 32 bit ODBC Administrator
-User DSN
-Add new User DSN (MyPostgreDsn), check connection
4.Connect Excel to Postgre
-Data
-From other sources
-OleDb wizard
-Other/Advanced
-Microsoft OLE DB Provider for ODBC drivers
-Connection - use connection string - Build
-Machine Data Source
-Choose created data source (MyPostgreDsn)
-Ok
-Test Connection
-Ok
-Choose tableā€¦

Related

Oracle VBA connection string

How does one properly establish a connection string for integrating a macro-enabled PowerPoint to be able to query an Oracle database? I have seen many old youtube videos and online tutorials regarding this (mostly in excel), but the connection string appears differently in each one. I am using a 64 bit Windows machine and an Oracle database that I usually access through SQL Developer.
A reference link that appears to be in the right direction:
http://learnexcelmacro.com/wp/2011/11/oracle-connection-string-in-vba/
I am trying to use a connection with the service, so it should look something like this:
The only changes that I have personally made to the connection string are:
HOST is Hostname founder in SQL Developer instance properties
Port is Port in SQL Developer instance properties
Uid is username in SQL Developer instance properties
Pwd is password in SQL developer instance properties
I have left all other fields unchanged. It should be noted that I do in fact have Tools>References>Microsoft ActiveX Data Objects 2.8 Library
I understand that inside of SQL Developer you can view the properties for a database instance connection. Is all the information there to construct my connection string? I cannot get the connection string to work and I am constantly met with errors.
Thanks!
There are several drivers available to connect to an Oracle database from VBA.
Common are ODBC Driver, either from Microsoft or from Oracle or the OLE DB provider. OLE DB provider are also either from Microsoft or from Oracle. There are even a few more from 3rd party (see How to connect to Oracle 11 database from . net), but lets keep it simple.
Depending on which driver you choose, the connection string is different:
ODBC Driver from Microsoft: Driver={Microsoft ODBC for Oracle};...
ODBC Drvier from Oracle: Driver={Oracle in OraClient11g_home1};... (or similar)
OLE DB Provider from Microsoft: Provider=MSDAORA;...
OLE DB Provider from Oracle: Provider=OraOLEDB.Oracle;...
For details have a look at Oracle Connection Strings or Connection String Home Page
All these drivers/providers require at least an Oracle Instant client installed on your machine. When your PowerPoint is 32-bit then also the Oracle client and as well the driver/provider must be 32-bit. When your PowerPoint is 64-bit then all other components must be also 64-bit - you cannot mix 32-bit and 64-bit.
The Oracle drivers provided by Microsoft are deprecated for ages, they are not available for 64-bit! So, when you have a 64-bit Office then {Microsoft ODBC for Oracle} and MSDAORA are out of the game.

Programmatically Import Ms Excel file to SQL Server

I need to create a procedure to upload data from an MS Excel spreadsheet to SQL server on command. My background is in Access VBA I am attempting to use either of the below Distributed Query methods as described on the Microsoft support website: (https://support.microsoft.com/en-us/help/321686/how-to-import-data-from-excel-to-sql-server). My table name and filename are different, otherwise I am using the exact code below. I receive the error: The OLE DB provider "Microsoft.ACE.OLEDB.4.0 has not been registered." I've tried other OLEDB versions to no avail. Not sure how to check which version of the driver I need. The SQL server that I am working with is 64 bit but my local machines are 32 bit and I think this is causing issues. If anyone can help simplify this issue and point me in the right direction I would much appreciate it. I am well versed in VBA with some SQL background. Other than that I don't have much programming background. Thank you!
SELECT * INTO XLImport3 FROM OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0',
'Data Source=C:\test\xltest.xls;Extended Properties=Excel 8.0')...[Customers$]
SELECT * INTO XLImport4 FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:\test\xltest.xls', [Customers$])
The query:
SELECT * INTO [TableName]
FROM OPENDATASOURCE( 'Microsoft.ACE.OLEDB.12.0', 'Excel 12.0 Xml; Database=' + [SpreadsheetFullPath] + ';IMEX=1'' )...[' + [WorksheetName] + '$]'
Notes:
Keep in mind that the query is executed on the SQL server so [SpreadsheetFullPath] is the path on the server and not the local machine.
UNC paths (\\sharedDir\...) are accepted.
Keep Excel worksheets to be imported simple.
When something fails, the errors returned by this driver are very unhelpful, so try to avoid them by observing 3.
You may need to install drivers on the database server: Office 2010, Office 2016
There is a bigmuscled engine called SSIS (Sql Server Importing Services) that does this, with error reporting, transformation of data, scheduling etc. It may already exist on your server. This is not the place to describe it in detail but there are tutorials on youtube. During the years the design environment has either been standalone or a plugin in Visual Studio.
It will sure solve your importing problems, but there is a (steep) learning curve. (Which may pay off in you increased skills!). After SSIS you can continue to SSRS and SSAS but that is another story!
Your current problem is the driver name in the "connection string". It often depends on your server's OS-version. (I.e. what has (not) been installed). Instead of guessing (as I have done, developing on XP and at first deploying blindly on Win7 and Win10), I suggest you ask your Admins to on your server make a ODBC connection DSN file connecting to that Excel file of yours, and then look at the contents of that DSN file. It will contain the connection string and the driver name you are looking for, that suits your server's installation. I have also found that "default port#" may suddenly be required in the string as well when connecting to Sql Server.

How do you link MS Access 2016 to Visual Fox Pro dbf tables as linked tables?

I have a Visual FoxPro set of tables (.dbf extension) which I want to create linked tables to in MS Access. The forums I have checked seem to indicate that the vfpodbc.dll is no longer supported. I have installed the new OLE driver, but it does not appear as an option in the Linked table manager for selection. I can access this driver from Excel 2016.
Question:
Am I limited to using the programatic link method via VBA or is there a way to get this to work using the Linked table manager?
My OS is Windows 10.
Visual FoxPro Software is "INFUSION version 8.414"
Using the FoxPro OLEDB driver, you will have to connect programmatically. There's no way to link tables the way you can from an ODBC data source.
Microsoft Dropped it's support since MS Jet 2.6, but you can try to use Advantage Database Server OBDC driver

Filemaker ODBC metadata missing in SSIS / SQL

I am having trouble gaining access to FileMaker Pro 11 data through the ODBC connection and starting to believe that it is not possible.
I have installed the odbc drivers supplied with the installation (11.03.76.00) locally to the FileMaker database, having worked out that they will not work remotely to the server. Have setup and successfully tested a system DSN.
When I try to use that System DSN within SQL Server or SSIS (same underlying process), I am gaining access to the list of tables and can preview the data, however when each process tries to get the metadata regarding the tables it fails.
SQL lets me select the tables / columns, preview the data, match it to destination and change the data types, but then fails on the next step of checking the conversion
SSIS provides list of tables / columns, data preview, but fails to list the columns (im guessing because it cannot work out the types)
FileMaker tech support does not cover the ODBC driver which has led me to believe it does not work...
Has anyone successfully attached to FileMaker Pro though the version 11 of the driver with SSIS or SQL? I need to automate a daily extract - any other ideas?
As billinkc points (above comment - sorry cannot convert comment into an answer), you can use the Script component as a Source and program around the ODBC driver issues.
The FileMaker Pro 11 odbc driver is data type aware, but they are not plumbed in correctly. The work around requires converting each column to string and then TryParse'ing to the correct data type.

How to force SQL Server 2008 express import from Excel to a specific data type?

I'd like to force SQL Management Studio - Import Data - from XLS excel file to read one column as specific data type? It does a type guessing. My first N rows contain decimal data, but some later columns have also characters in there. I know I need to specify IMEX=1 in the connection string to the XLS file, but as far as I know this could be done only if I were using ADO.NET application to do it. (this forces Jet engine to honor registry setting HKML\Software\Microsoft\Jet\4.0\Engines\Excel\ImportMixedTypes which is set to Text).
It could also be done if I had developer/enterprise edition of sql server 2008, and editing DTS package to include the connection string. But I use Express edition that does not allow saving DTS packages - what are my other options? Thanks
Use the OLE DB Provier for Access Database Engine (or Jet depending on version of Excel), click the 'Properties' button to bring up the 'Data Link Properties' dialog, click the 'All' tab and in the list edit the 'Extended Properties' item to add IMEX=1.
Where to get the OLE DB provider? The version for the Access Database Engine, known as ACE, which was released as part of Access2007, can be used to open Jet 4.0 data sources including Excel spreadsheets. It can be downloaded from MSDN as 2007 Office System Driver: Data Connectivity Components. The stated supported operating systems are: Windows 7, Windows Vista, Windows Server 2008, Windows Server 2003 and Windows XP. There could be an equivalent for Access2010 but I'm out of the loop.
Add a first row having text data that you remove from the target table after importing the data.